рег. Email-ext Плагин
В конвейерном задании вы можете использовать действия после сборки / попробовать перехватить с правильным шагом - ref. на почту
pipeline {
agent any
stages {
stage('Test') {
steps {
sh 'echo "Fail!"; exit 1'
}
}
}
post {
always {
echo 'This will always run'
}
success {
echo 'This will run only if successful'
}
failure {
echo 'This will run only if failed'
}
unstable {
echo 'This will run only if the run was marked as unstable'
}
changed {
echo 'This will run only if the state of the Pipeline has changed'
echo 'For example, if the Pipeline was previously failing but is now successful'
}
}
}
или try-catch (скриптовым способом)
try{
//code to handle
} catch (e) {
emailext (
from: 'sender@domain.com',
to: 'recepient@domain.com',
subject: "job failed- ${env.JOB_NAME}, Build #${env.BUILD_NUMBER}, FAILED",
attachLog: true,
body: """
Foooooo text
For current build refer to: ${env.BUILD_URL}
job: ${env.JOB_NAME}
build number: #${env.BUILD_NUMBER}
With ERROR:
${e.message}
For full log refer to
${env.BUILD_URL}
"""
)
throw e
}