down to 1 todo in the 1-click pipeline!
Some checks failed
gitea.arg.rip/_template-service/pipeline/head There was a failure building this commit

This commit is contained in:
adam 2024-11-19 02:08:20 -05:00
parent b3853befc8
commit 7aed478531

38
Jenkinsfile vendored
View File

@ -1,14 +1,14 @@
pipeline {
agent any
environment {
linuxServiceAccount=credentials('UUID')
productiondatabase_connectionString="?"
targetServer="string"
linuxServiceAccount=creds
productiondatabase_connectionString=creds
targetHost=string
}
stages {
stage('build'){
//"hey self, what if once in your life you try a *different* language?" "then i'll update this file, moai.emoji."
//dotnetBuild(outputDirectory: "./", project: "Deployment/Deployment.csproj")
dotnetBuild(outputDirectory: "./dist", project: "$REPO_NAME.csproj")
}
stage('test'){
//TODO: run tests
@ -22,9 +22,14 @@ pipeline {
branch "release"
}
steps{
sh 'ssh ${env.targetServer} rm -rf temp_deploy'
sh 'ssh ${env.targetServer} mkdir -p temp_deploy'
sh 'scp -r dist ${env.targetServer}:temp_deploy'
sshagent([linuxServiceAccount])
{
ssh ${env.targetHost} 'bash -s' << 'ENDSSH'
rm -rf temp_deploy
mkdir -p temp_deploy
ENDSSH
sh 'scp -r dist ${env.targetHost}:temp_deploy'
}
}
}
stage ('stop')
@ -34,13 +39,15 @@ pipeline {
}
steps{
script{
//user is the service user
ssh ${env.targetServer} 'bash -s' << 'ENDSSH'
systemctl --user stop $svcname
sshagent([linuxServiceAccount]) {
ssh ${env.targetHost} 'bash -s' << 'ENDSSH'
systemctl --user stop $REPO_NAME
ENDSSH
}
}
}
}
---dbstart---
stage ('backup db')
{
when {
@ -58,13 +65,16 @@ pipeline {
//TODO: update database
//TODO: if updating the db fails, restore the old one
}
---dbend---
stage ('replace')
{
when {
branch "release"
}
steps{
sh 'ssh ${env.targetServer} "rm -rf dist/ && mv temp_deploy/ dist/"'
sshagent([linuxServiceAccount]) {
ssh ${env.targetHost} "rm -rf dist/ && mv temp_deploy/ dist/"
}
}
}
stage ('spin up')
@ -74,11 +84,13 @@ pipeline {
}
steps{
script{
ssh ${env.targetServer} 'bash -s' << 'ENDSSH'
systemctl --user start $svcname
sshagent([linuxServiceAccount]) {
ssh ${env.targetHost} 'bash -s' << 'ENDSSH'
systemctl --user start $REPO_NAME
ENDSSH
}
}
}
}
}
}