I have Job in Jenkins that sends an email after the build with a HTML report in its body using email-ext plugin by setting Default content to this :
${FILE,path="absolute_path/index.html"}
I want to add to this (my body mail ) the URL of the build of this job. How is that possible ?
$BUILD_URL is the easiest way to do it, just add it in your Body mail and it will show the hyperlink of your latest build. Show activity on this post. Optionally specify the HTTP address of the Jenkins installation, such as http://yourhost.yourdomain/jenkins/.
The Jenkins URL is a combination of your system's hostname and the port used by Jenkins. For instance, when logging in on your system using the default port 8080: http://localhost:8080/env-vars.html.
$BUILD_URL
is the easiest way to do it, just add it in your Body mail and it will show the hyperlink of your latest build.
Small update to this question:
First of all, you need to set Jenkins URL
in your system configuration to access such URLs:
Jenkins -> Manage Jenkins -> Configure System -> Jenkins Location -> Jenkins URL
It set to http://localhost:8080/
by default (if you accepted this during initial start of Jenkins)
Optionally specify the HTTP address of the Jenkins installation, such as http://yourhost.yourdomain/jenkins/. This value is used to let Jenkins know how to refer to itself, ie. to display images or to create links in emails.
This is necessary because Jenkins cannot reliably detect such a URL from within itself.
Then you can access the build or job URLs via BUILD_URL
or JOB_URL
environment variables in your Groovy pipeline script.
For example:
println env.BUILD_URL
println env.JOB_URL
You also can find more such environment variables for your Jenkins instance on this page:
http://localhost:8080/env-vars.html/ (replace localhost:8080
with your Jenkins URL)
${PROJECT_URL}
in the body of email will be resolved to a hyperlink to your job.
Kindly Specified in the Default content under editable email configuration in Jenkins
//build_url is fetched the URL of Build //allure/ its append with URL for Allure reporting browser URL
${FILE,readFile("$BUILD_URL/allure/")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With