Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make an URL a result of Hudson build

Tags:

jenkins

hudson

I have a build job which uploads results to a certain URL.

How can I have a link to that URL shown on the build page?

I've tried to create an html page with redirect and add it to the artifacts but it seems a bit weird.

like image 895
Sergey Grinev Avatar asked Dec 29 '12 14:12

Sergey Grinev


People also ask

What is Jenkins build URL?

For a locally hosted Jenkins server, the URL would be: http://localhost:8080/env-vars.html.

How do I download from Jenkins?

Download the latest stable Jenkins WAR file to an appropriate directory on your machine. Open up a terminal/command prompt window to the download directory. Run the command java -jar jenkins. war .


2 Answers

Per job run? Or global for the whole job?

If your link is always static (example: latest artifacts only), you can use a Sidebar link plugin. https://wiki.jenkins-ci.org/display/JENKINS/Sidebar-Link+Plugin that will place a static link per job (for all runs).

If your link changes per run, here is what I do in my environment. I update the run's description with an <a href> tag. The link won't show on the run page, however it works rather nicely in the build history.

enter image description here
Note above, the [Debug] and [Release] are unique links for each particular build.

For this, you would need Description Setter Plugin. https://wiki.jenkins-ci.org/display/JENKINS/Description+Setter+Plugin. And in the plugin (it is post-build action), just write pure HTML. You can use usual environment variables in there

<a href="http://whatever/${BUILD_NUMBER}">Link here</a>

Edit: note that nowadays it isn't that easy (if at all possible) to put html in the build history description. It does work on the individual build page.

like image 142
Slav Avatar answered Oct 08 '22 17:10

Slav


If you want markup to be treated as such, you must enable it: Manage Jenkins > Global Security > Markup Formatter = Safe HTML

Then, for Jenkins scripted pipelines, you can simply set the currentBuild.description property with some HTML. Example:

currentBuild.description = "Click <a href='http://yourlink'>here</a>"

The rendered HTML will show in the build history and on the build page.

If you don't see "Safe HTML" in the Markup Formatter drop-down, you probably need to install the OWASP Markup Formatter plugin.

At the time of this post, the Blue Ocean GUI will not display HTML for build descriptions. See issue here: https://issues.jenkins.io/browse/JENKINS-45719

This Chrome extension can serve as a workaround: https://chrome.google.com/webstore/detail/blue-ocean-description-ht/maahpenodjcdhodbonmdkfgnceddigae

like image 23
Adam Bennett Avatar answered Oct 08 '22 18:10

Adam Bennett