From 0260b3fb841f88561f25d44624d9c27bd7bc394f Mon Sep 17 00:00:00 2001 From: romanshved <80713735+romanshved@users.noreply.github.com> Date: Mon, 14 Jun 2021 19:29:07 +0300 Subject: [PATCH] Update Jenkinsfile --- Jenkinsfile | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 700025c09..1915bd689 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,18 +3,17 @@ pipeline { stages { stage('Build') { steps { - echo 'Running build automation' - sh './gradlew build --no-daemon' - archiveArtifacts artifacts: 'dist/trainSchedule.zip' + echo 'Running build' + archiveArtifacts artifacts: 'index.html' } } stage('Build Docker Image') { when { - branch 'master' + branch 'main' } steps { script { - app = docker.build("willbla/train-schedule") + app = docker.build("romanshved/index") app.inside { sh 'echo $(curl localhost:8080)' } @@ -23,7 +22,7 @@ pipeline { } stage('Push Docker Image') { when { - branch 'master' + branch 'main' } steps { script { @@ -36,24 +35,24 @@ pipeline { } stage('DeployToProduction') { when { - branch 'master' + branch 'main' } steps { input 'Deploy to Production?' milestone(1) withCredentials([usernamePassword(credentialsId: 'webserver_login', usernameVariable: 'USERNAME', passwordVariable: 'USERPASS')]) { script { - sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@$prod_ip \"docker pull willbla/train-schedule:${env.BUILD_NUMBER}\"" + sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@$prod_ip \"docker pull romanshved/index:${env.BUILD_NUMBER}\"" try { - sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@$prod_ip \"docker stop train-schedule\"" - sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@$prod_ip \"docker rm train-schedule\"" + sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@$prod_ip \"docker stop index\"" + sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@$prod_ip \"docker rm index\"" } catch (err) { echo: 'caught error: $err' } - sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@$prod_ip \"docker run --restart always --name train-schedule -p 8080:8080 -d willbla/train-schedule:${env.BUILD_NUMBER}\"" + sh "sshpass -p '$USERPASS' -v ssh -o StrictHostKeyChecking=no $USERNAME@$prod_ip \"docker run --restart always --name index -p 8080:8080 -d romanshved/index:${env.BUILD_NUMBER}\"" } } } } } -} \ No newline at end of file +}