Skip to content

Instantly share code, notes, and snippets.

@Osein
Last active June 30, 2019 19:39
Show Gist options
  • Select an option

  • Save Osein/9b484df1c6c0eb8e686001ea100cb322 to your computer and use it in GitHub Desktop.

Select an option

Save Osein/9b484df1c6c0eb8e686001ea100cb322 to your computer and use it in GitHub Desktop.
stage('Init') {
steps {
script {
lastCommitInfo = sh(script: "git log -1", returnStdout: true).trim()
commitContainsSkip = sh(script: "git log -1 | grep '.*\\[skip ci\\].*'", returnStatus: true)
if(commitContainsSkip == 0) {
skippingText = "Skipping commit."
env.shouldBuild = false
currentBuild.result = "NOT_BUILT"
}
slackMessage = "*${env.JOB_NAME}* *${env.BRANCH_NAME}* received a new commit. ${skippingText}\nHere is commmit info: ${lastCommitInfo}"
}
}
}
stage('Send info to Slack') {
steps {
slackSend color: "#2222FF", message: slackMessage
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment