script {
def job = build job: '<job>'
if (job.getResult().equals('FAILURE')) {
def jobName = '<job>'
def date = new Date().format('dd/MM/yyyy')
echo "Build Result: " job.getResult()
slackSend color: "danger", message: "${jobName} failed on " date "\n Build URL - ${absoluteUrl}"
}
else {
echo "Build Result: " job.getResult()
}
}
How to get the build url for ''.
By using 'JOB_URL' I get the url of the Parent Job.
And 'absoluteUrl' throws ' No such property: absoluteUrl for class: groovy.lang.Binding
' error.
Thanks for the help.
CodePudding user response:
absoluteUrl
is not defined. job.getAbsoluteUrl()
would give you the URL.
See documentation