Hi there,
I want to write an email, when the build succeeded (via blue ocean).
Therefore I use the ext email plugin, however I need to build the link via groovy script, I want to add in the body text with groovy:
post
{
success
{
script
{
def jobList = ${env.JOB_NAME}.tokenize("/")
def baseJobName = jobList[0];
jobList.removeAt(0)
def jobRest = jobList.join("/")
}
emailext(
subject: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at "<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>
<p><a href='${env.JENKINS_URL}/blue/organizations/jenkins/${baseJobName}/detail/${jobRest}/${env.BUILD_NUMBER}/pipeline'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a></p>
""",
recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)
}
}
For unkown reason the post action will not be executed and I also do not see any logs why it failed. The log is empty.
How can I send en mail via groovy? Or what is the correct approch the scope, declarative and scripting code?
Can anybody help?
Regards,
Zack