_template-service/Jenkinsfile
adam 7aed478531
Some checks failed
gitea.arg.rip/_template-service/pipeline/head There was a failure building this commit
down to 1 todo in the 1-click pipeline!
2024-11-19 02:08:20 -05:00

96 lines
2.8 KiB
Groovy

pipeline {
agent any
environment {
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: "./dist", project: "$REPO_NAME.csproj")
}
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{
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')
{
when {
branch "release"
}
steps{
script{
sshagent([linuxServiceAccount]) {
ssh ${env.targetHost} 'bash -s' << 'ENDSSH'
systemctl --user stop $REPO_NAME
ENDSSH
}
}
}
}
---dbstart---
stage ('backup db')
{
when {
branch "release"
}
steps{
//TODO: backup database
}
}
stage ('update db')
{
when {
branch "release"
}
//TODO: update database
//TODO: if updating the db fails, restore the old one
}
---dbend---
stage ('replace')
{
when {
branch "release"
}
steps{
sshagent([linuxServiceAccount]) {
ssh ${env.targetHost} "rm -rf dist/ && mv temp_deploy/ dist/"
}
}
}
stage ('spin up')
{
when {
branch "release"
}
steps{
script{
sshagent([linuxServiceAccount]) {
ssh ${env.targetHost} 'bash -s' << 'ENDSSH'
systemctl --user start $REPO_NAME
ENDSSH
}
}
}
}
}
}