Skip to content

Instantly share code, notes, and snippets.

@perfecto25
Created October 7, 2021 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perfecto25/df22ba3cffe18b58d4dafb2a6b5ade1e to your computer and use it in GitHub Desktop.
Save perfecto25/df22ba3cffe18b58d4dafb2a6b5ade1e to your computer and use it in GitHub Desktop.
sample Jenkins pipeline with slack notifications (slack plugin)
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