Skip to content

Commit 2eea523

Browse files
committed
Add checking new commit on the 'bump version' and 'deploy' stage
Signed-off-by: Jeonghyuk Park <[email protected]>
1 parent 2abc227 commit 2eea523

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

Jenkinsfile

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ def MASTER_BRANCH = "master"
7575
*/
7676
def GIT_REVISION_LOOKUP = 'git log -n 1 --pretty=format:%h'
7777

78+
/**
79+
* Variables to check any new commit since the previous successful commit
80+
*/
81+
def GIT_COMMIT = "null"
82+
def GIT_PREVIOUS_SUCCESSFUL_COMMIT = "null"
83+
7884
/**
7985
* This is the product name used by the build machine to store information about
8086
* the builds
@@ -130,8 +136,13 @@ pipeline {
130136
stage("Clean workspace and checkout source") {
131137
steps {
132138
timeout(time: 5, unit: 'MINUTES') {
133-
cleanWs()
134-
checkout scm
139+
script {
140+
cleanWs()
141+
scmInfo = checkout scm
142+
143+
GIT_COMMIT = scmInfo.GIT_COMMIT
144+
GIT_PREVIOUS_SUCCESSFUL_COMMIT = scmInfo.GIT_PREVIOUS_SUCCESSFUL_COMMIT
145+
}
135146
}
136147
}
137148
}
@@ -542,6 +553,9 @@ pipeline {
542553
expression {
543554
return BRANCH_NAME == MASTER_BRANCH
544555
}
556+
expression {
557+
return GIT_COMMIT != GIT_PREVIOUS_SUCCESSFUL_COMMIT
558+
}
545559
}
546560
}
547561
steps {
@@ -591,7 +605,10 @@ pipeline {
591605
return PIPELINE_CONTROL.deploy
592606
}
593607
expression {
594-
return BRANCH_NAME == MASTER_BRANCH
608+
return BRANCH_NAME == MASTER_BRANCH
609+
}
610+
expression {
611+
return GIT_COMMIT != GIT_PREVIOUS_SUCCESSFUL_COMMIT
595612
}
596613
}
597614
}
@@ -622,7 +639,6 @@ pipeline {
622639
}
623640
}
624641
}
625-
626642
}
627643
post {
628644
unsuccessful {

0 commit comments

Comments
 (0)