From 64e98ac28921278a4d75347d7725e6ced530959b Mon Sep 17 00:00:00 2001 From: Mihai Georgescu Date: Mon, 4 Dec 2023 09:53:42 +0200 Subject: [PATCH] Update Jenkinsfile --- Jenkinsfile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 16bbed451..38fceb153 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -46,9 +46,7 @@ pipeline { stage('Tag the docker image') { when { // Condition to execute the stage when the branch is main - expression { - return (env.CHANGE_ID == null && env.BRANCH_NAME != 'main') - } + changeRequest() } steps { echo "now we will tag the docker image" @@ -99,9 +97,11 @@ pipeline { } stage('Tag docker image again for the main repo') { when { - // Condition to execute the stage when the branch is main - changeRequest() + // Condition to execute the stage when the branch is 'main' + expression { + return env.BRANCH_NAME == 'main' } + } steps { echo "now we will tag the docker image for the main branch" script { @@ -116,9 +116,11 @@ pipeline { } stage('Push docker image to main repository') { when { - // Condition to execute the stage when the branch is main - changeRequest() + // Condition to execute the stage when the branch is 'main' + expression { + return env.BRANCH_NAME == 'main' } + } steps { echo "now we will push the image to the docker main repository" script {