Skip to content

Instantly share code, notes, and snippets.

@teeks99
Created June 29, 2018 15:02
Show Gist options
  • Save teeks99/d7c331b3f66a9fe6507cfdaaabbd9229 to your computer and use it in GitHub Desktop.
Save teeks99/d7c331b3f66a9fe6507cfdaaabbd9229 to your computer and use it in GitHub Desktop.
Jenkinsfile with e-mail
pipeline {
agent any
stages {
stage('Build'){
steps {
echo "Running job: ${env.JOB_NAME}\nbuild: ${env.BUILD_ID} - ${env.BUILD_URL}\nblue ocean: ${env.RUN_DISPLAY_URL}"
}
}
}
post {
failure {
mail to: 'notify-list@example.com', from: 'jenkins@example.com',
subject: "Example Build: ${env.JOB_NAME} - Failed",
body: "Job Failed - \"${env.JOB_NAME}\" build: ${env.BUILD_NUMBER}\n\nView the log at:\n ${env.BUILD_URL}\n\nBlue Ocean:\n${env.RUN_DISPLAY_URL}"
}
}
}
@InbarRose
Copy link

thank you, this is very well explained and presented. exactly what I needed.
Note: You can also add "${currentBuild.fullDisplayName}" and "${currentBuild.currentResult}" for niceness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment