Skip to content

Commit

Permalink
Merge pull request #1673 from alohaeditor/f-gpu-1755
Browse files Browse the repository at this point in the history
Add option to skip build, if git commit is equal to git commit of last
  • Loading branch information
npomaroli authored Jun 7, 2024
2 parents 57d1830 + c62479c commit b01d5f2
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ spec:
}

parameters {
booleanParam(name: 'checkGitCommit', defaultValue: false, description: 'If set to true, the current git revision is compared with the git revision of the last successful build. If they are equal, the build is skipped and env.BUILD_SKIPPED is set to true')
booleanParam(name: 'unitTests', defaultValue: true, description: 'Whether to run the unit tests')
booleanParam(name: 'release', defaultValue: false, description: 'Whether to perform a release')
booleanParam(name: 'releaseWithNewChangesOnly', defaultValue: true, description: 'Release: Abort the build if there are no new changes')
Expand All @@ -75,7 +76,31 @@ spec:
}

stages {
stage('Check git commit') {
when {
expression {
return Boolean.valueOf(params.checkGitCommit)
}
}

steps {
script {
if ( env.GIT_COMMIT == env.GIT_PREVIOUS_SUCCESSFUL_COMMIT ) {
echo "env.GIT_COMMIT (" + env.GIT_COMMIT + ") = env.GIT_PREVIOUS_SUCCESSFUL_COMMIT (" + env.GIT_PREVIOUS_SUCCESSFUL_COMMIT + "). Skip building."
env.BUILD_SKIPPED = "true"
} else {
echo "env.GIT_COMMIT (" + env.GIT_COMMIT + ") != env.GIT_PREVIOUS_SUCCESSFUL_COMMIT (" + env.GIT_PREVIOUS_SUCCESSFUL_COMMIT + "). Need to rebuild."
}
}
}
}

stage('Build, Deploy') {
when {
expression {
return env.BUILD_SKIPPED != "true"
}
}
steps {
githubBuildStarted()

Expand Down Expand Up @@ -138,7 +163,7 @@ spec:
stage("Publish release") {
when {
expression {
return Boolean.valueOf(release)
return Boolean.valueOf(release) && env.BUILD_SKIPPED != "true"
}
}

Expand Down

0 comments on commit b01d5f2

Please sign in to comment.