Skip to content

Badges, badges, badges!

Compare
Choose a tag to compare
@jan-molak jan-molak released this 16 Jan 01:14
· 528 commits to master since this release

Have you ever wanted to make the code coverage, compiler warnings or some other build stat more visible? Well, now you can!

screen shot 2017-01-15 at 22 38 05

This build brings a number of other improvements too:

  • The status of the External Build Jobs is displayed correctly (#265, #266) - thanks @hschink!
  • The animated build progress bar is displayed correctly in IE11/Edge (#272)
  • Even though the anonymous analytics were not gathered if you opted out, the script was still loaded causing an unnecessary HTTP request. This is no longer the case. (#276) - thanks @larsrh!
  • Instead of displaying the description of a failure set by the Build Failure Analyzer, Build Monitor now display its name making the information much more concise #275 - thanks @patrickdepinguin!

To set a badge:

  • Install the Groovy Post-Build Plugin
  • Add a Groovy Postbuild post-build action to a Jenkins project of your choice
  • Configure the Groovy script to call either:
    • manager.addShortText(textToDisplay) which sets a badge with default colours
    • manager.addShortText(textToDisplay, textColour, backgroundColour, borderWidth, borderColour) which sets a badge using custom CSS attributes. For example: manager.addShortText('Deployed', 'black', '#b4d455', '1px', 'green')

The above steps are documented in the acceptance tests, together with the accompanying screenshots.

The cool thing about the Groovy Postbuild plugin is that it has access to quite a lot of your build data via Jenkins core APIs, which you can see in their examples.

If you wanted to show the number of failing unit tests, for example, you could read the data from the TestResultAction object and configure the Groovy Postbuild action as follows:

def result = manager.build.testResultAction.result
def total  = result.totalCount
def failed = result.failCount

manager.addShortText(failed + " / " + total + " failed")

🗣 What information are your badges going to show? And how are you going to script it? Let me know on twitter and maybe we could compile a little cookbook for the Build Monitor Community :-)


You might be aware that I've been busy working on Serenity/JS, a next generation acceptance and regression testing library.

If you're working with modern web apps and have "learn some new tools" on your list of New Year's Resolutions or you're interested in doing acceptance testing at scale, please check out serenity-js.org and let me know what your think!

Best,
Jan


Do you find Build Monitor useful? Support its development :)

Give it a star! ★
Found a bug? Raise an issue or submit a pull request.
Have feedback? Let me know on twitter: @JanMolak