Skip to content

Latest commit

 

History

History
174 lines (106 loc) · 6.62 KB

README.adoc

File metadata and controls

174 lines (106 loc) · 6.62 KB

Badge Plugin

Build Status Codecov Coverage Jenkins Security Scan

Installations Contributors Changelog

Introduction

Changelog

Since version 1.10 release notes are recorded in GitHub Releases.

Changelogs for older releases can be found in the archive.

Version 2.x

Version 2.0 is a major rework of the original plugin and introduces lots of new features. More details on this can be found in the Release Notes for 2.0.

Version 1.x

Legacy version that was originally forked from the Groovy Postbuild Plugin.

Usage

Badges

Badge

addBadge

This is the central pipeline step that allows users to add custom badges to their builds. A badge can either be an icon or text that can optionally be formatted as HTML rather than plain text. Users can also add links to the badges as well as styling to get the desired visual results.

Examples

See Jenkins Pipeline Steps Reference for detailed descriptions of the supported parameters.

// add a badge with an icon and text
def badge = addBadge(icon: 'symbol-rocket plugin-ionicons-api', text: 'Launching ...')

// update the icon and text during build time
badge.setIcon('symbol-planet-outline plugin-ionicons-api')
badge.setText('Lunar orbit reached, proceed landing maneuver ...')

// update the icon and text during build time
badge.setIcon('symbol-american-football-outline plugin-ionicons-api')
badge.setText('Huston, we have touchdown!')

// remove the badge
removeBadges(id: badge.getId())

// add another badge with html formatted text and css style
addBadge(text: '<i>Apollo 11 landed on the moon!</i>', style: 'color: var(--success-color)')
AddBadge
Figure 1. Badges can be added, modified and removed during a build

addInfoBadge

A convenience pipeline step that adds an info icon alongside a tooltip text and optional link.

Examples

See Jenkins Pipeline Steps Reference for detailed descriptions of the supported parameters.

// add a badge with an info icon and text
def badge = addInfoBadge(text: 'Launching in ...')

// update the text during build time
badge.setText('10 ...')
badge.setText('9 ...')
badge.setText('8 ...')
AddInfoBadge
Figure 2. An info badge with icon and hover text

addWarningBadge

A convenience pipeline step that adds a warning icon alongside a tooltip text and optional link.

Examples

See Jenkins Pipeline Steps Reference for detailed descriptions of the supported parameters.

// add a badge with a warning icon, text and link
addWarningBadge(text: 'Houston, we have a problem ...', link: 'https://youtu.be/2Q_ZzBGPdqE')
AddWarningBadge
Figure 3. A warning badge with icon and hover text

addErrorBadge

A convenience pipeline step that adds an error icon alongside a tooltip text and optional link.

Examples

See Jenkins Pipeline Steps Reference for detailed descriptions of the supported parameters.

// add a badge with an error icon and text
addErrorBadge(text: 'Transmission failed!')
AddErrorBadge
Figure 4. An error badge with icon and hover text

Summaries

Summary

addSummary

This pipeline step allows users to add custom summaries to their build overview. A summary can consist of an icon and text that can optionally be formatted as HTML rather than plain text. Users can also add links to the summary as well as styling to get the desired visual results.

Examples

See Jenkins Pipeline Steps Reference for detailed descriptions of the supported parameters.

// add a summary with an icon, text and link
addSummary(icon: 'symbol-home-outline plugin-ionicons-api', text: 'Test Chamber prepared', link: 'https://jenkins.io')

// add another summary with an icon and text
def summary = addSummary(icon: 'symbol-people-outline plugin-ionicons-api', text: 'Looking for Test Subjects ...')

// removes a summary
removeSummaries(id: summary.getId())

// add another summary with an icon and formatted html as text
addSummary(icon: 'symbol-aperture-outline plugin-ionicons-api',
           text: '<b>Results:</b><li>Test Chamber ready</li><li>Test Subject missing</li>')
AddSummary
Figure 5. Summaries can be added, modified and removed during a build

Allow HTML in Badges and Summaries

The Badge Plugin uses Jenkins Markup Formatter to sanitize HTML in badges and summaries. This ensures safety when using HTML for texts and prevents malicious injections.

Markup Formatter Configuration
Figure 6. The Markup Formatter can be configured under Manage Jenkins → Security → Markup Formatter