Created
October 7, 2021 20:54
-
-
Save perfecto25/df22ba3cffe18b58d4dafb2a6b5ade1e to your computer and use it in GitHub Desktop.
sample Jenkins pipeline with slack notifications (slack plugin)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent any | |
stages { | |
stage("Deploy Config"){ | |
steps { | |
slackSend color: "#15FFE9", message: """Jenkins is deploying Config to: | |
env/host: ${ENVIRONMENT}${env.HOST} | |
branch: [${env.BRANCH}] | |
build# ${env.BUILD_NUMBER} | |
""" | |
echo "Deploying Config - environment: ${ENVIRONMENT}, host: ${HOST}, branch: ${BRANCH}" | |
sh '''#!/bin/bash | |
your bash code here | |
''' | |
} | |
} | |
} | |
post { | |
success { | |
slackSend color: "#54EC4F", message: """Jenkins DONE deploying Config to | |
env/host: ${ENVIRONMENT}${env.HOST} | |
branch: [${env.BRANCH}] | |
build# ${env.BUILD_NUMBER} | |
""" | |
} | |
failure { | |
slackSend color: "#FF0000", message: """Jenkins ERROR deploying Config to | |
env/host: ${ENVIRONMENT}${env.HOST} | |
branch: [${env.BRANCH}] | |
build# ${env.BUILD_NUMBER} | |
""" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment