From 9157d18f89a18619805cb2a2b681b4500a1fb5c2 Mon Sep 17 00:00:00 2001 From: surtexx <91895868+surtexx@users.noreply.github.com> Date: Mon, 13 Nov 2023 17:17:31 +0200 Subject: [PATCH] Update Jenkinsfile --- Jenkinsfile | 92 +++++++++++++++++++++-------------------------------- 1 file changed, 37 insertions(+), 55 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 334308e2b..7d3fc716d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,70 +1,52 @@ -pipeline{ - agent any - stages { - stage ("build") { - when { - expression { - return env.CHANGE_ID != null +if(env.CHANGE_ID != null){ + pipeline{ + agent any + stages { + stage ("build") { + steps { + echo "Running build automation..." + sh './mvnw checkstyle:checkstyle' + sh './mvnw verify' + sh './mvnw clean package -DskipTests=true' } } - steps { - echo "Running build automation..." - sh './mvnw checkstyle:checkstyle' - sh './mvnw verify' - sh './mvnw clean package -DskipTests=true' - } - } - stage ("Build Docker Image") { - when { - expression { - return env.CHANGE_ID != null + stage ("Build Docker Image") { + steps { + script{ + app = docker.build("surtexx/mr:${GIT_COMMIT[0..7]}", "-f Dockerfile1 .") + } } } - steps { - script{ - app = docker.build("surtexx/mr:${GIT_COMMIT[0..7]}", "-f Dockerfile1 .") - } - } - } - stage ("Push Docker Image") { - when { - expression { - return env.CHANGE_ID != null - } - } - steps { - script{ - docker.withRegistry('https://registry.hub.docker.com', 'docker_hub_login') { - app.push("${GIT_COMMIT[0..7]}") - app.push("latest") + stage ("Push Docker Image") { + steps { + script{ + docker.withRegistry('https://registry.hub.docker.com', 'docker_hub_login') { + app.push("${GIT_COMMIT[0..7]}") + app.push("latest") + } } } } } } } - -pipeline{ - agent any - stages{ - stage ("Build Docker Image") { - when{ - branch: 'main' - } - steps { - script{ - app = docker.build("surtexx/main", "-f Dockerfile1 .") +else if(env.BRANCH_NAME == "main"){ + pipeline{ + agent any + stages{ + stage ("Build Docker Image") { + steps { + script{ + app = docker.build("surtexx/main", "-f Dockerfile1 .") + } } } - } - stage ("Push Docker Image") { - when{ - branch: 'main' - } - steps { - script{ - docker.withRegistry('https://registry.hub.docker.com', 'docker_hub_login') { - app.push("latest") + stage ("Push Docker Image") { + steps { + script{ + docker.withRegistry('https://registry.hub.docker.com', 'docker_hub_login') { + app.push("latest") + } } } }