added timestamps and email recipient

This commit is contained in:
Bulat Yusupov 2020-07-16 12:41:37 +03:00
parent 9f653d471c
commit 41085705bd

36
Jenkinsfile vendored
View file

@ -2,6 +2,18 @@ pipeline {
agent any agent any
// using the Timestamper plugin we can add timestamps to the console log
options {
timestamps()
}
environment {
//Use Pipeline Utility Steps plugin to read information from pom.xml into env variables
IMAGE = readMavenPom().getArtifactId()
VERSION = readMavenPom().getVersion()
EMAIL_RECIPIENTS = 'byusupov@provectus.com'
}
stages { stages {
stage('Test') { stage('Test') {
steps { steps {
@ -9,4 +21,28 @@ pipeline {
} }
} }
} }
post {
// Always runs. And it runs before any of the other post conditions.
always {
// Let's wipe out the workspace before we finish!
deleteDir()
}
success {
sendEmail("Successful");
}
unstable {
sendEmail("Unstable");
}
failure {
sendEmail("Failed");
}
}
}
def sendEmail(status) {
mail(
to: "$EMAIL_RECIPIENTS",
subject: "Build $BUILD_NUMBER - " + status + " (${currentBuild.fullDisplayName})",
body: "Changes:\n " + getChangeString() + "\n\n Check console output at: $BUILD_URL/console" + "\n")
} }