Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the easiest way to display information on the Jenkins UI from a groovy system script?

I am very reluctant to jump into having to write a full fledged plugin, and I only know of one way to inject some information onto the build status screen of a build: set the build description.

I would like to display and dynamically update a more complex piece of rendering onto the build status page from a groovy system script. What is the best way to achieve it? Do I have to write a full plugin and grok the whole stapler paradigm?

like image 241
Christian Goetze Avatar asked Oct 08 '15 17:10

Christian Goetze


People also ask

How do I use Groovy script in Jenkins?

Usage. To create Groovy-based project, add new free-style project and select "Execute Groovy script" in the Build section, select previously configured Groovy installation and then type your command, or specify your script file name. In the second case path taken is relatively from the project workspace directory.

How do we get system information on the Jenkins dashboard?

In the Jenkins dashboard, click Manage Jenkins from the left hand side menu. Then click on 'Configure System' from the right hand side. In the Home directory, you will now see the new directory which has been configured.

What is use Groovy sandbox in Jenkins?

The option “Use Groovy Sandbox,” shown below, is available in the Pipeline tab, and it allows the scripts to be run by any user without requiring administrator privileges. In this case, the script is run only by using the internal accessible APIs (which allow you to develop your script by using Groovy).

What Jenkins command line script can you use to view the list of plugins?

You can retrieve the information using the Jenkins Script Console which is accessible by visiting http://<jenkins-url>/script .


1 Answers

I had good experience with the following 2 plugins, both were used from within a pipeline:

  1. The Groovy Postbuild Plugin - just use manager.createSummary and add HTML to it. I found this to be easy to implement, with great UI results - it looks like built-in Jenkins sections. This is my personal recommendation.
  2. As already suggested by stanjer, The Summary Display Plugin also works. However, it is more cumbersome to use, as you need to generate a custom XML file with non-standard HTML tags in it, then add it as a build artifact and reference to it from the plugin.
like image 149
Oren Chapo Avatar answered Sep 30 '22 19:09

Oren Chapo