Skip to main content

Jenkins library

Purpose

cnp-jenkins-library is a Jenkins shared library that defines the HMCTS common pipeline: an opinionated Continuous Delivery pipeline that builds, tests and deploys code to production while enforcing a standard set of checks — unit tests, security checks, Sonar scanning, container builds, smoke and functional tests.

When to use it

Use this library if your repository builds on HMCTS Jenkins. It provides:

  • withPipeline(type, product, component) — the opinionated application pipeline for java, nodejs, angular and python services
  • withInfraPipeline(product) — the opinionated infrastructure pipeline for Terraform-only repositories, such as shared infrastructure
  • withNightlyPipeline(type, product, component) — the nightly pipeline for scheduled tests such as security scans, fortify and performance tests

Before using it, your repository must be added to Jenkins.

How to import it

Jenkins is already configured with this library under the name Infrastructure, so there is nothing to install. Import it at the top of your Jenkinsfile_CNP, pinned to a release:

#!groovy

@Library("Infrastructure@2.7.1") _

def type = "java"        // "java", "nodejs", "angular" or "python"
def product = "rhubarb"
def component = "recipe-backend"

withPipeline(type, product, component) {
  enableSlackNotifications('#my-team-builds')
}

The application pipeline deploys branches to environments as follows:

Branch Environment
master aat then prod
demo demo
perftest perftest
PR branch preview

The full set of options — Key Vault secrets, high level data setup, API gateway tests, pact contract testing and more — is documented in the library README.

Versioning

The library is released as version tags, and pinning to a release is the default way to consume it:

@Library("Infrastructure@2.7.1") _

A bare @Library("Infrastructure") follows the library’s master branch and picks up every change as soon as it merges. Avoid this — pin to a release so your pipeline only changes when you choose to update it.

Pinned repositories do not receive new pipeline features, fixes or security updates until the pin is updated, so review and update your pin regularly. The available versions are listed on the library releases page.

To test an unmerged library change, reference the branch instead:

@Library("Infrastructure@my-feature-branch") _

Branches must first be added to the allowed library branches list and that change merged to master, otherwise the pipeline will fail.

Real examples

This page was last reviewed on 8 September 2026. It needs to be reviewed again on 8 March 2027 by the page owner platops-build-notices .