How do you display a clickable repo link in the Jenkins output? - jenkins

In my Jenkins Console logs it says:
Obtained jenkins/some.jenkinsfile from git ssh://mygitserver.myorg.com/my/git/repo.git
so I have to copy / paste / edit to get that repo then click about to the Jenkinsfile in your browser.
When you're doing this multiple times every day it becomes a major headache.
Is there anyway to get a simple clickable link?

I would suggest crafting an output that would then become clickable. i.e. declare the link then specify the file using a variable.
script { println("https://yourRepoUrl.com/jenkins/${downloadFile}) }
Alternatively, you could download the file from within the pipeline. See here for details

Related

Associate an external application url to jenkins build

I am trying to link or associate an external application url to jenkins job build.
So for every builds, this link or url should be available at the left side and any user can simply click on it to launch the external application.
So far I explored the following plugins for this:
https://wiki.jenkins.io/display/JENKINS/Associated+Files+Plugin - this associates a file or directory to the build , something similar to the html publisher plugin... not a url
https://wiki.jenkins.io/display/JENKINS/DocLinks+Plugin - similar to above , associate a doc from the build artifact directories
https://wiki.jenkins.io/pages/viewpage.action?pageId=52298023 - this Side bar link plugin can associate a external link to the jenkin project, but not to every builds
for me the external link which I am trying to associate to the build , dynamically changes for each build , basically some of the query parameter in the external link, so it's critical to associate it to every builds for tracking and other purposes . ex: the external link will be a like a small web app
http:hostnamexxx:port/somepage?para1=xxx&para2=yyyy
Please let me know if there is any plugin for this specific purpose or any other ideas
This would be the Anchor Chain plugin. I've played around with it a bit:
The docs state that the icon can be omitted. Then however you need to insert a tab character after the URL.
When inserting a link to an icon, it is always relative to Jenkins base URL.

create hyperlink to file server in pipeline jobs console

I want to print a hyperlink to a file I created while running a pipeline job. This simple .txt file should be opened after hitting the link. I found this wiki entry but there is no example implementation. Is there a way to perform this? I dont know how to trigger the 'explorer' call. (this is for windows use only)
I used : '<file://link/to/folder/>' and its working ;)

Change SpecFlow+ runner report output link

We are using Jenkins in our build cycle to run our specflow tests. We are trying to find a better way to surface the test results. The generated html report file is great, but right now we have to manually log into the build server to check it out. I want to surface that file via a clickable link.
Here is what I am talking about specifically. Here is the test results via our Jenkins console
I want to change the highlighted text to an http url so that everyone can just click that and view the file.
I already have the http link working, so that's not the issue. I just need to figure out how to make specrun output this link here.
Any ideas on if this is possible? And if so how to do it?
Thanks for the help!
Sorry, this is currently not possible in SpecFlow+Runner, but I will put it on the backlog as a feature request.
Perhaps you can do something in Jenkins to parse the output and reformat the link.
Full disclosure: I am on of the developers of the SpecFlow+Runner.

Make an URL a result of Hudson build

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.
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.
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
Link here
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.
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

Jenkins: Display last console output on project page

When viewing a project in Jenkins, I'd like to see the last console output displayed on the project page.
This satisfies two needs:
I most often just want to see what the output of the build was; clicking through to the last console output seems needlessly cumbersome
Non-technical management can't remember how to / aren't sufficiently motivated to click through to the last console output in cases where the output is relevant to them if only they were to easily see it
I've looked for plugins that support this but can't find any.
What options do I have?
First an easy solution: job descriptions (push 'edit description' button on the main job page) admit HREF links. Make that link your latest build console permalink (http://[jenkins_server]/job/[job-name]/lastBuild/console).
If even one click is too much, here's a possible solution: you can use log contents as the description of your job. You can update your job via Jenkins CLI with:
java -jar jenkins-cli.jar -s http://[jenkins-server] update-job [job-name] < config.xml
So what you need to do is this: after your jobs run, trigger another job that will take the triggering job and console output file as parameters, substitute <description> in the job's config.xml with the contents of the console file (with proper escaping, etc.), and run the update command as above. Of course, this solution is labor-intensive and bug-prone.
I had this same questions myself and I ended up finding this option useful...
http://[jenkins-server]/job/[job-name]/[build-number|lastBuild]/logText/progressiveText?start=0
Edit: This no longer works in the current version of Jenkins
Similar to malenkiy_scot's answer, you can actually embed iframes in the description.
I use:
<iframe src='lastBuild/consoleText' style='width: 80%; height: 500px'></iframe>
as my project description, and it shows the latest console text in the project description page.
I just created a plugin that displays console output of latest build at the project page.
https://github.com/jenkinsci/display-console-output-plugin
To use this plugin, you have to type mvn hpi:hpi to create a display-console-output.hpi file. Then upload this plugin from http://localhost:8080/pluginManager/advanced.
You can simply just use one of these plugins:
http://wiki.hudson-ci.org/display/HUDSON/Hudson+Personal+View
https://wiki.jenkins-ci.org/display/JENKINS/Console+Column+Plugin
May be you don't need it, you can click in the status button in the left of each build, each button show console output for each build.
Of course, this feature may not be operative in all Jenkins versions.
The solution for your problem is the https://wiki.jenkins-ci.org/display/JENKINS/Extra+Columns+Plugin plugin for Jenkins. After installing it you may modify your view to add a button for the console output as an additional column.
For a declarative pipeline, you can show a link to the console right where the progress bar shows up by adding this line at the very top of the file:
currentBuild.description = """Job console"""
This depends on a plugin and a setting, both of which were already on my system:
The OWASP Markup Formatter plugin provides the setting Security > Configure Global Security > Markup Formatter, which should be set to "Safe HTML".
The setting Jenkins -> Manage Jenkins -> Configure System -> Jenkins Location -> Jenkins URL needs to be the URL of your Jenkins installation.

Resources