Explain Codes LogoExplain Codes Logo

Html in Jenkins job descriptions

html
jenkins-plugins
configuration-as-code
safe-html
Alex KataevbyAlex Kataev·Dec 6, 2024
TLDR

To embed HTML in Jenkins job descriptions, look no further than the Safe HTML plugin. Here's how to get it working:

  1. Navigate to Manage Jenkins > Configure Global Security.
  2. Set the Markup Formatter option to Safe HTML.

Take a look at this example:

<b>Build:</b> <span style="color:green;">Success</span>

Keep in mind, only a subset of HTML tags is permissible, in the interest of security.

Plugins and Configuration

Let's break down your journey to richer job descriptions in Jenkins:

Deploying Safe HTML via GUI

If you're in a hurry and need a quick fix:

  1. Go to Manage Jenkins > Configure Global Security.
  2. Find the Markup Formatter option and toggle it to Safe HTML to let your HTML shine through.

Going programmable with JASC Plugin

For those preferring the programmer zest of Configuration as Code, consider the CASC plugin:

  1. Insert markupFormatter: safeHtml in your config file.
  2. Apply your configurations, and you've got HTML-supportive job descriptions!

CASC is a lifesaver when it comes to simultaneous Jenkins setups - it makes your configuration versionable and testable.

Staying updated

Jenkins has a penchant for updates, so keep an eye on the release notes. Always triple-check to make sure your settings are compatible with your current Jenkins version.

Mastering the Tips & Traps

Employing HTML in Jenkins job descriptions may come with quirks, but no worries. We've got your back:

Syntax Highlighting

If you're going HTML, double-check whether disableSyntaxHighLighting is set to false in your Jenkins setup. Trust me, it makes your HTML more readable.

// Who wouldn't love some beautiful highlighting, right?

Use those inbuilt links Jenkins offers while setting up the security configurations. They're not there for fun - they guide you right!

// Click those blue words, they won't bite

Ensuring Safe HTML

Before jumping in, ascertain your custom HTML doesn't comprise active content like JavaScript or spooky CSS. Don't let your Jenkins fall prey to security threats.

// Safety first! Jenkins loves secure code, maybe even more than its morning coffee.