Skip to content

Commit

Permalink
Merge pull request #45 in OPENDEVSTACK/ods-jenkins-shared-library fro…
Browse files Browse the repository at this point in the history
…m feature/allow-skip-builds to production

* commit 'ac66796963f9ccc14d7754ef20b2a0d3e9eb525d':
  Updating log message on build skip
  marking Jenkins status as NOT_BUILT when skipping build
  removing explicit return
  allow to skip builds
  • Loading branch information
Soman,Akhil (BI X) BIX-DE-I committed Mar 8, 2019
2 parents e68bbad + ac66796 commit 85d7c03
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/org/ods/Context.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,6 @@ interface Context {
int getOpenshiftBuildTimeout()

def setEnvironmentCreated(boolean created)

boolean getCiSkip()
}
6 changes: 6 additions & 0 deletions src/org/ods/OdsContext.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ class OdsContext implements Context {
script: "oc get bc/${buildConfigName} -n ${config.openshiftProjectId} -o jsonpath='{.spec.source.git.ref}'"
).trim()
}
// looks for string [ci skip] in commit message
boolean getCiSkip() {
script.sh(
returnStdout: true, script: 'git show --pretty=%s%b -s'
).toLowerCase().contains('[ci skip]')
}

// Given a branch like "feature/HUGO-4-brown-bag-lunch", it extracts
// "HUGO-4" from it.
Expand Down
8 changes: 8 additions & 0 deletions src/org/ods/OdsPipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ class OdsPipeline implements Serializable {
script.wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
script.checkout script.scm
script.currentBuild.displayName = "#${context.tagversion}"

if (context.ciSkip){
logger.info 'Skipping build due to [ci skip] in the commit message ...'
script.currentBuild.result = 'NOT_BUILT'
setBitbucketBuildStatus('SUCCESSFUL')
return
}

stages(context)
}
script.currentBuild.result = 'SUCCESS'
Expand Down

0 comments on commit 85d7c03

Please sign in to comment.