jenkinsfile hopefully more like the good working one in test236
Some checks failed
gitea.arg.rip/_template-service/pipeline/head There was a failure building this commit

more changes to come
This commit is contained in:
adam 2024-12-07 01:55:09 -05:00
parent cd1e610dd3
commit 47f7c9d2b1

54
Jenkinsfile vendored
View File

@ -7,12 +7,18 @@ pipeline {
} }
stages { stages {
stage('build'){ stage('build'){
steps{
//"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: "./dist", project: "$REPO_NAME.csproj") dotnetBuild(outputDirectory: "./dist", project: "$REPO_NAME.csproj")
} }
}
stage('test'){ stage('test'){
steps{
//TODO: run tests //TODO: run tests
//TODO: publish tests in some nicely readable format //TODO: publish tests in some nicely readable format
sh """#!/bin/bash
"""
}
} }
stage ('upload') { stage ('upload') {
when { when {
@ -22,13 +28,12 @@ pipeline {
branch "release" branch "release"
} }
steps{ steps{
sshagent([linuxServiceAccount]) withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccount, keyFileVariable: 'PK')])
{ {
ssh ${env.targetHost} 'bash -s' << 'ENDSSH' sh """#!/bin/bash
rm -rf temp_deploy ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'rm -rf temp_deploy & mkdir -p temp_deploy'
mkdir -p temp_deploy scp -i \"${PK}\" -r dist ${linuxServiceAccount_USR}@${env.targetHost}:temp_deploy
ENDSSH """
sh 'scp -r dist ${env.targetHost}:temp_deploy'
} }
} }
} }
@ -38,16 +43,14 @@ pipeline {
branch "release" branch "release"
} }
steps{ steps{
script{ withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccount, keyFileVariable: 'PK')])
sshagent([linuxServiceAccount]) { {
ssh ${env.targetHost} 'bash -s' << 'ENDSSH' sh """#!/bin/bash
systemctl --user stop $REPO_NAME ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'systemctl --user stop $REPO_NAME'
ENDSSH """
} }
} }
} }
}
---dbstart---
stage ('backup db') stage ('backup db')
{ {
when { when {
@ -55,6 +58,8 @@ pipeline {
} }
steps{ steps{
//TODO: backup database //TODO: backup database
sh """#!/bin/bash
"""
} }
} }
stage ('update db') stage ('update db')
@ -62,18 +67,24 @@ pipeline {
when { when {
branch "release" branch "release"
} }
steps{
//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
sh """#!/bin/bash
"""
}
} }
---dbend---
stage ('replace') stage ('replace')
{ {
when { when {
branch "release" branch "release"
} }
steps{ steps{
sshagent([linuxServiceAccount]) { withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccount, keyFileVariable: 'PK')])
ssh ${env.targetHost} "rm -rf dist/ && mv temp_deploy/ dist/" {
sh """#!/bin/bash
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'rm -rf dist/ && mv temp_deploy/ dist/'
"""
} }
} }
} }
@ -83,12 +94,11 @@ pipeline {
branch "release" branch "release"
} }
steps{ steps{
script{ withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccount, keyFileVariable: 'PK')])
sshagent([linuxServiceAccount]) { {
ssh ${env.targetHost} 'bash -s' << 'ENDSSH' sh """#!/bin/bash
systemctl --user start $REPO_NAME ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'systemctl --user start $REPO_NAME'
ENDSSH """
}
} }
} }
} }