21

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?

Jon Cram
  • 16,609
  • 24
  • 76
  • 107

8 Answers8

19

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.

malenkiy_scot
  • 16,415
  • 6
  • 64
  • 87
9

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
Yassin Hajaj
  • 21,337
  • 9
  • 51
  • 89
Phillip Fleischer
  • 1,023
  • 12
  • 14
4

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.

Nathan T
  • 123
  • 1
  • 6
  • 2
    How this works? I just added the above code in description area, however it is not updating with any console text. Can you please let me know how can i show the last build link in project description/dashboard? – Noundla Sandeep Feb 26 '14 at 08:48
  • 2
    The latest Jenkins says the field is "escaped html" and indeed it does not render. So I too am curious if we can do this. – AnneTheAgile Feb 04 '15 at 23:47
  • 1
    You're right, this doesn't work in the latest versions of Jenkins. I'll post again if I come up with a new solution. – Nathan T Feb 06 '15 at 16:45
2

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.

enter image description here

Brian
  • 12,145
  • 20
  • 90
  • 153
1

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.

Carlos
  • 11
  • 1
1

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.

col.panic
  • 2,944
  • 4
  • 25
  • 31
  • 1
    This plugin can only add console output button in the view page, not the project page. – Brian Mar 23 '17 at 08:07
1

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

Arek
  • 1,941
  • 4
  • 22
  • 27
  • 1
    Neither of those plugins allow for displaying the last console output on the project page – Jon Cram Feb 29 '12 at 12:08
  • Yes, you are right - my bad. But then again they go a step further and allow displaying last console straight from the overall view. Wouldn't it be even better for your non-technical management? – Arek Feb 29 '12 at 12:22
0

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 = """<a href="${JOB_URL}lastBuild/console">Job console</a>"""

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.
Noumenon
  • 5,099
  • 4
  • 53
  • 73