_template-service/Jenkinsfile

84 lines
2.4 KiB
Plaintext
Raw Normal View History

2024-11-16 22:19:51 -05:00
pipeline {
agent any
environment {
linuxServiceAccount=credentials('UUID')
productiondatabase_connectionString="?"
targetServer="string"
}
2024-11-16 22:19:51 -05:00
stages {
2024-11-17 13:23:08 -05:00
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")
2024-11-17 13:23:08 -05:00
}
stage('test'){
//TODO: run tests
//TODO: publish tests in some nicely readable format
}
stage ('upload') {
when {
//now my CI/CD is no longer continuous, it's just... automatic.
//(which is what I actually want tbh)
//but that does mean I have to put this condition in every single branch
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'
2024-11-17 13:23:08 -05:00
}
}
stage ('stop')
{
when {
branch "release"
}
steps{
script{
//user is the service user
ssh ${env.targetServer} 'bash -s' << 'ENDSSH'
systemctl --user stop $svcname
ENDSSH
}
2024-11-17 13:23:08 -05:00
}
}
stage ('backup db')
{
when {
branch "release"
}
steps{
//TODO: backup database
}
2024-11-17 13:23:08 -05:00
}
stage ('update db')
{
when {
branch "release"
}
//TODO: update database
//TODO: if updating the db fails, restore the old one
}
stage ('replace')
{
when {
branch "release"
}
steps{
sh 'ssh ${env.targetServer} "rm -rf dist/ && mv temp_deploy/ dist/"'
}
2024-11-17 13:23:08 -05:00
}
stage ('spin up')
{
when {
branch "release"
}
steps{
script{
ssh ${env.targetServer} 'bash -s' << 'ENDSSH'
systemctl --user start $svcname
ENDSSH
}
2024-11-17 13:23:08 -05:00
}
2024-11-16 22:19:51 -05:00
}
}
}