diff --git a/Jenkinsfile b/Jenkinsfile index e3e8fb3b9..603b39a0d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,5 +8,33 @@ pipeline { archiveArtifacts artifacts: 'dist/trainSchedule.zip' } } - } -} \ No newline at end of file + stage('DeployToStaging') { + when { + branch 'master' + } + steps { + withCredentials([usernamePassword(credentialsId: 'webserver_login', usernameVariable: 'USERNAME', passwordVariable: 'USERPASS')]) { + sshPublisher( + failOnError: true, + continueOnError: false, + publishers: [ + sshPublisherDesc( + configName: 'staging', + sshCredentials: [ + username: "$USERNAME", + encryptedPassphrase: "$USERPASS" + ], + transfers: [ + sshTransfer( + sourceFiles: 'dist/trainSchedule.zip', + removePrefix: 'dist/', + remoteDirectory: '/tmp', + execCommand: 'sudo /usr/bin/systemctl stop train-schedule && rm -rf /opt/train-schedule/* && unzip /tmp/trainSchedule.zip -d /opt/train-schedule && sudo /usr/bin/systemctl start train-schedule' + ) + ] + ) + ] + ) + } + } + }