I often find myself in a position where I have multiple Jenkins servers that are almost clones of each other. In many cases, this is because I run a “test” Jenkins where we develop jobs, test them, then promote them over to our “prod” Jenkins server. Because the servers look identical, I’m always afraid I might make some destructive change on the wrong server. I want some simple, even hacky way to make temporary style changes that won’t persist when I move things between the Jenkins servers.
SIDE NOTE: If you’re looking for a more permanent, style-ish (intentional pun) way of customizing your Jenkins server, please investigate the multiple plugins that Jenkins has for customizing the look and feel.
The quickest hack (and I emphasize hack) that I’ve found is to play with the images (PNG) files that Jenkins uses to display it’s headers. When we look at any standard Jenkins page, it looks like this:
In my case, ALL my Jenkins servers looked exactly like that, making it very difficult to tell which was which.
If you do a little clicking around using your favorite browser’s development tools, you can investigate the HTML and CSS that’s generated by Jenkins.
You’ll find that it uses image files that are unpacked/stored into some link such as /static/b93128ha31/title.png on the server. These exist in the jenkins.war file that gets exploded when you run Jenkins. It may take you a while, but you can usually find them on the server somewhere. If you’re running in tomcat, you might find them neatly stashed down the /webapps/ tree. I was running the simple embedded container, so I eventually found mine in /var/cache/jenkins on my redhat server. Specifically, I did a ‘ps ax | grep jenkins’ and found the process that had defined ‘–webroot=/var/cache/jenkins/war’ when it started.
Once this is done, you can poke around in the /var/cache/jenkins/war/images directory and see the images that Jenkins uses for basic display stuff. For simplicity, I chose the the ‘title.png’ which is the “Jenkins” title image in the top bar.
I simply re-created another text block “DO-T Jenkins” (using PowerPoint in my case), then saved it as a PNG image. “DO-T” stands for DevOps-TEST. It’s useful if it has a transparent background so you don’t have to worry about matching the background black color.
I transferred it up to my server, dropped it into the images directory on top of the original title.png file and “voila!” I now have a custom Jenkins banner.
This change will get erased any time the war file gets re-exploded. Depending on your server configuration, this could be every time you restart Jenkins or only when you update to a new version. For my particular situation, this was perfectly acceptable since I only wanted the change to be temporary and live until I was done with my test server.