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

42
Jenkinsfile vendored
View File

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