diff --git a/.gitignore b/.gitignore index ca1c7a3..773c1db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +appsettings.json + # ---> VisualStudio ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. diff --git a/Jenkinsfile b/Jenkinsfile index eee3cca..bff5f9d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,6 +2,7 @@ pipeline { agent any environment { linuxServiceAccount=creds + linuxServiceAccountID=string productiondatabase_connectionString=creds targetHost=string } @@ -28,7 +29,7 @@ pipeline { branch "release" } steps{ - withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccount, keyFileVariable: 'PK')]) + 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' @@ -43,7 +44,7 @@ pipeline { branch "release" } steps{ - withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccount, keyFileVariable: 'PK')]) + withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccountID, keyFileVariable: 'PK')]) { sh """#!/bin/bash ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'systemctl --user stop $REPO_NAME' @@ -51,24 +52,21 @@ pipeline { } } } - stage ('backup db') - { - when { - branch "release" - } - steps{ - //TODO: backup database - sh """#!/bin/bash - """ - } - } stage ('update db') { when { branch "release" } steps{ - //TODO: update database + //TODO: backup database + sh """#!/bin/bash + """ + + sh """#!/bin/bash + pushd dist + dotnet ef database update --connection "${env.productiondatabase_connectionString}" + popd + """ //TODO: if updating the db fails, restore the old one sh """#!/bin/bash """ @@ -80,7 +78,7 @@ pipeline { branch "release" } steps{ - withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccount, keyFileVariable: 'PK')]) + withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccountID, keyFileVariable: 'PK')]) { sh """#!/bin/bash ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'rm -rf dist/ && mv temp_deploy/ dist/' @@ -94,7 +92,7 @@ pipeline { branch "release" } steps{ - withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccount, keyFileVariable: 'PK')]) + withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccountID, keyFileVariable: 'PK')]) { sh """#!/bin/bash ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'systemctl --user start $REPO_NAME'