post {
always {
echo 'One way or another, I have finished'
deleteDir() /* clean up our workspace */
}
success {
echo 'I succeeeded!'
}
unstable {
echo 'I am unstable :/'
}
failure {
echo 'I failed :('
}
changed {
echo 'Things were different before...'
}
}
}
in a Groovy pipleline?
I'm looking at using "something" to notify by email if a build fails
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/da5927cf-2fc5-4c46-9734-8db06b87be7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
try
{
}
catch(any)
{
println('Error occurred during build:'); println(any.toString()); println('Marking build as FAILURE because of this'); currentBuild.result = 'FAILURE' throw any //rethrow exception to prevent the build from proceeding}
finally
{
if(!currentBuild.result) { currentBuild.result = 'SUCCESS' println("Current build result is undefined, setting it as ${currentBuild.result}") } // send email
emailext body: 'my email body', subject: 'email subject', to: 'te...@test.dev', replyTo: 'te...@test.dev', mimeType: 'text/html';
}
If you use currentBuild.currentResult (was added a few months ago IIRC) you get a value that will never be null.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/dfdf3042-8b26-4f83-b43f-a17b8142a4a3%40googlegroups.com.
If you use currentBuild.currentResult (was added a few months ago IIRC) you get a value that will never be null.
From: jer...@bodycad.com
Sent: 04 December 2017 17:06
To: Jenkins Users
Subject: Re: Translation between declaritive pipleline and groovy pipeline
You need to wrap your groovy code into a try/catch/finally block and check the current build result ( I also give you some hint when things are not yet filled)
try
{
}
catch(any)
{
println('Error occurred during build:');println(any.toString());
println('Marking build as FAILURE because of this');
currentBuild.result = 'FAILURE'
throw any //rethrow exception to prevent the build from proceeding
}
finally
{
if(!currentBuild.result){
currentBuild.result = 'SUCCESS'
println("Current build result is undefined, setting it as ${currentBuild.result}")
}
// send email
emailext body: 'my email body', subject: 'email subject', to: 'te...@test.dev', replyTo: 'te...@test.dev', mimeType: 'text/html';
}
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/dfdf3042-8b26-4f83-b43f-a17b8142a4a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/5a266724.43af500a.705b8.e595%40mx.google.com.To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.