forked from adam/discord-bot-shtik
hopefully ready for release
This commit is contained in:
parent
401a3ecbc8
commit
e4384a2ea0
89
Jenkinsfile
vendored
89
Jenkinsfile
vendored
@ -1,6 +1,11 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
environment {
|
||||||
|
linuxServiceAccount=credentials("a83b97d0-dbc6-42d9-96c9-f07a7f2dfab5")
|
||||||
|
linuxServiceAccountID="3ca1be00-3d9f-42a1-bab2-48a4d7b99fb0"
|
||||||
|
database_connectionString=credentials("e0e068dd-57e4-4e2b-b6b2-9d9f0d21adeb")
|
||||||
|
targetHost="alloces.lan"
|
||||||
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('clean old'){
|
stage('clean old'){
|
||||||
steps{
|
steps{
|
||||||
@ -10,16 +15,88 @@ pipeline {
|
|||||||
stage('Build') {
|
stage('Build') {
|
||||||
steps {
|
steps {
|
||||||
sh 'dotnet publish vassago.csproj --configuration Release --os linux'
|
sh 'dotnet publish vassago.csproj --configuration Release --os linux'
|
||||||
archiveArtifacts artifacts: 'bin/Release/net7.0/linux-x64/publish/*'
|
archiveArtifacts artifacts: 'bin/Release/net9.0/linux-x64/publish/*'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Deploy'){
|
stage ('upload') {
|
||||||
when{
|
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"
|
branch "release"
|
||||||
}
|
}
|
||||||
steps{
|
steps{
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccountID, keyFileVariable: 'PK')])
|
||||||
|
{
|
||||||
|
sh """#!/bin/bash
|
||||||
|
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'rm -rf temp_deploy & mkdir -p temp_deploy'
|
||||||
|
scp -i \"${PK}\" -r dist ${linuxServiceAccount_USR}@${env.targetHost}:temp_deploy
|
||||||
|
"""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage ('stop')
|
||||||
|
{
|
||||||
|
when {
|
||||||
|
branch "release"
|
||||||
|
}
|
||||||
|
steps{
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccountID, keyFileVariable: 'PK')])
|
||||||
|
{
|
||||||
|
sh """#!/bin/bash
|
||||||
|
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'systemctl --user stop test274'
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage ('update db')
|
||||||
|
{
|
||||||
|
when {
|
||||||
|
branch "release"
|
||||||
|
}
|
||||||
|
steps{
|
||||||
|
//TODO: backup database
|
||||||
|
sh """#!/bin/bash
|
||||||
|
"""
|
||||||
|
|
||||||
|
sh """#!/bin/bash
|
||||||
|
dotnet ef database update --connection "${env.database_connectionString}"
|
||||||
|
"""
|
||||||
|
//TODO: if updating the db fails, restore the old one
|
||||||
|
sh """#!/bin/bash
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage ('replace')
|
||||||
|
{
|
||||||
|
when {
|
||||||
|
branch "release"
|
||||||
|
}
|
||||||
|
steps{
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccountID, keyFileVariable: 'PK')])
|
||||||
|
{
|
||||||
|
sh """#!/bin/bash
|
||||||
|
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'mv dist/appsettings.json appsettings.json'
|
||||||
|
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'rm -rf dist/ && mv temp_deploy/ dist/'
|
||||||
|
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'mv appsettings.json dist/appsettings.json'
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage ('spin up')
|
||||||
|
{
|
||||||
|
when {
|
||||||
|
branch "release"
|
||||||
|
}
|
||||||
|
steps{
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccountID, keyFileVariable: 'PK')])
|
||||||
|
{
|
||||||
|
sh """#!/bin/bash
|
||||||
|
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'systemctl --user start test274'
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user