I want to send email after post build action in jenkins. Hence I have write jenkinsfile as follows. But I need some groovy script for 1. Attachment for zip file 2. Before attaching the file , I need to convert the folder to zip format.
Note: Please don't suggest email plugin procedure & configuration. I preferred Jenkins file method configuration
pipeline {
agent any
stages {
stage('Testing') {
steps {
sh 'chmod +x mvnw'
sh './mvnw clean verify serenity:aggregate'
}
}
}
post {
failure {
script {
mail (to: 'email@gmail.com',
subject: "Job '${env.JOB_NAME}' (${env.BUILD_NUMBER}) failed",
body: "Please visit ${env.BUILD_URL} for further information"
);
}
}
success {
script {
mail (to: 'email@gmail.com',
subject: "Job '${env.JOB_NAME}' (${env.BUILD_NUMBER}) success.",
body: "Please visit ${env.BUILD_URL} for further information.",
);
}
}
}
}