I have a Jenkinsfile and I want to send out a links to the Blue Ocean webpage in the body of the notification e-mail should a failure occurs. This will let other developers know that something went wrong and so that they know where to begin to look. This is what I have at the moment in my Jenkinsfile:
always {
echo "Test run completed"
script {
EMAIL_TEXT = "THE BUILD HAPPENED"
email_recipients = emailextrecipients(["foo@bar.com"])
emailext(body: "${EMAIL_TEXT}",
mimeType: 'text/html',
subject: "Build Notification: ${JOB_NAME}-Build# ${BUILD_NUMBER} ${currentBuild.result}",
from: 'hello@bar.com',
to: "${email_recipients}".trim()
)
}
}
What I don't understand is what I need to add/change to make this work. And I can only go through the Jenkinsfile, this is due to admin restraints that I'm working with right now.
Blue Ocean is a Jenkins plugin that is being used: https://plugins.jenkins.io/blueocean/
I've tried looking through documentation, but have not found something that will shed light on my ignorance of this specific edge-case.
Generally, the URL for the logs in blue ocean are in this form:
http://your-jenkins-server/blue/organizations/jenkins/${JOB_NAME}/detail/${JOB_NAME}/${BUILD_NUMBER}/pipeline
You can create the URL using the format above and send this in your email. If you additionally only want this email to file when the build fails, add it under a failure
block.