Notice: Undefined index: height in /var/www/ on line 27
Jenkins –

Jenkins (2)

Custom Folder Icons for Jenkins

I was looking around for a Jenkins Plugin that would allow me to customize the icon of a Folder as we use folders to separate projects at work. To my annoyance i only found a plugin that requires using Cloudbees own hosted Jenkins solution (Jenkins Folder Plugin Plus). The plugin Custom Job Icon Plugin does closely what i want to achieve but only works for plain jobs and ignores folders for some reason.

For a moment i even considered writing my own Jenkins plugin to remedy this, but i ended up utilizing the userContent-folder and the Simple Theme Plugin that allows you to also execute custom javascript. This works because the files in the $JENKINS_HOME/userContent folder is reachable from http://JENKINS_URL/userContent. jQuery is also included in the frontend of Jenkins so i was able to utilize that to check for existing icons in /userContent/job-FOLDER_NAME.png with a HEAD ajax request.

So if you, like me, have been scouring the web for a simple solution to pimp your Jenkins folders then put the below JavaScript in /userContent and refer to it from the simple-theme plugin in the system configuration of Jenkins.

Here is the script:

Create a Jenkins Support Channel

When creating a large Jenkins setup, it is often a good idea to consider have a team governing, documenting, and managing the tools a little. These teams almost always require a clear support channel, otherwise everything becomes tribal knowledge, and that is not going to scale well.

Signature of a large Jenkins setup means it has

  • Multiple workers with varying operating systems
  • Multiple integrations to systems for static analysis, artifact repositories and code-review platform triggers such as pull-requests and patch sets
  • Support for an advanced authorization role strategy or single sign on from other platforms
  • Support for multiple build-systems such as MSBuild, Maven, Gradle, Ant, Make and so forth

When a large number of teams with a similarly large number of software development stacks starts to use it. Then it becomes relevant with being able to support the systems by providing a clear and obvious support-channel.

A common channel for issue-management is JIRA, which ironically started as an ITSM-platform. And another common place to store documentation is whatever source-control platform you have available, such as GitHub Pages, Wikimedia or Confluence.

So i would like to show how to include custom-integration in the Jenkins header directly into those tools.

Starting point

Configure JIRA Issue Collector

  • In JIRA, create a target project
  • Go to settings for the project
  • Go to Issue Collectors
  • Click + Add issue collector
  • Configure it as you may wish, make sure your select custom trigger-style
  • Submit the collector
  • Extract the link in the markup JIRA wants you to embed.

The collector-link will look something like this

Configure Jenkins to embed collector and run some JavaScript

  • Go to Manage Jenkins
  • Go to System Configuration
  • Fill in Issue Collector URL: with the collector-link from the previous step.
  • Fill in the Theme Javascript part with an accessable location where you save this JavaScript. SonaType Nexus rawFiles-store works nicely for this purpose.
  • Get the following html
  • Put it into the system message
  • preview html should now put two buttons in the header
  • If you want you can include custom styling to the buttons in the simple theme css box. I used the following to achieve the looks below.

And voila! You have opened a support channel directly from your Jenkins header into your documentation and added support for adding JIRA issues directly into your JIRA project! Clicking the Report an issue! will open a JIRA Modal and allow your users to fill in a support issue as their own JIRA users.

Issue collectors can be customized to pre-populate fields quite extensively, read more on Atlassians own documentation.