# hmcts/cnp-jenkins-library architecture

> Architecture diagram of the GitHub repository hmcts/cnp-jenkins-library, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hmcts/cnp-jenkins-library
- Repository: https://github.com/hmcts/cnp-jenkins-library

## Overview

This is a Jenkins Shared Library for HMCTS application and infrastructure pipelines. A consuming Jenkinsfile loads the library; its opinionated pipeline entry points coordinate build, test, security and deployment stages, while separate entry points support infrastructure and nightly work. The README also identifies performance testing and Pact contract testing as capabilities. Source excerpts are limited to build configuration and an audit-transform script, so component relationships below rely on the README’s documented workflow; no unsampled implementation calls are asserted.

Main entry points: [`vars/withPipeline.groovy`](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/withPipeline.groovy) (App pipeline), [`vars/withInfraPipeline.groovy`](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/withInfraPipeline.groovy) (Infrastructure pipeline), [`vars/withNightlyPipeline.groovy`](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/withNightlyPipeline.groovy) (Nightly pipeline), [`vars/withEnvironmentAgent.groovy`](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/withEnvironmentAgent.groovy) (Environment agents)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entrypoints["Pipeline entry points"]
  node_app_pipeline["App pipeline"]
  node_infra_pipeline["Infrastructure pipeline"]
  node_nightly_pipeline["Nightly pipeline"]
end

subgraph group_delivery["Application delivery"]
  node_build_test["Build and test"]
  node_docker["Docker build<br/>[Docker.groovy]"]
  node_deploy_aks["AKS deployment"]
  node_deploy_environment["Environment deployment"]
  node_promote["Build promotion"]
end

subgraph group_infrastructure["Infrastructure delivery"]
  node_infra_build["Infrastructure build"]
  node_infra_shared["Shared infrastructure"]
  node_environment_agent["Environment agents"]
  node_subscription["Subscription access"]
end

subgraph group_quality["Quality and integrations"]
  node_security["Security checks"]
  node_fortify["Fortify scanning<br/>[fortifyScan.groovy]"]
  node_pact["Pact testing<br/>[PactBroker.groovy]"]
  node_performance["Performance testing<br/>[Gatling.groovy]"]
  node_dynatrace["Dynatrace testing"]
end

node_jenkins(("Jenkins consumer"))

node_jenkins -->|"loads library"| node_app_pipeline
node_jenkins -->|"loads library"| node_infra_pipeline
node_jenkins -->|"loads library"| node_nightly_pipeline
node_app_pipeline -->|"runs stages"| node_build_test
node_app_pipeline -->|"runs checks"| node_security
node_app_pipeline -->|"builds image"| node_docker
node_app_pipeline -->|"deploys to AKS"| node_deploy_aks
node_app_pipeline -->|"deploys environment"| node_deploy_environment
node_app_pipeline -->|"promotes build"| node_promote
node_infra_pipeline -->|"runs stages"| node_infra_build
node_infra_pipeline -->|"supports infrastructure"| node_infra_shared
node_app_pipeline -->|"uses scoped agents"| node_environment_agent
node_infra_pipeline -->|"uses scoped agents"| node_environment_agent
node_jenkins -->|"runs block"| node_subscription
node_nightly_pipeline -->|"supports performance tests"| node_performance
node_nightly_pipeline -->|"supports performance tests"| node_dynatrace
node_app_pipeline -->|"supports contract tests"| node_pact
node_app_pipeline -->|"supports security scans"| node_fortify

click node_app_pipeline "https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/withPipeline.groovy"
click node_infra_pipeline "https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/withInfraPipeline.groovy"
click node_nightly_pipeline "https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/withNightlyPipeline.groovy"
click node_build_test "https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/sectionBuildAndTest.groovy"
click node_docker "https://github.com/hmcts/cnp-jenkins-library/blob/master/src/uk/gov/hmcts/contino/Docker.groovy"
click node_deploy_aks "https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/sectionDeployToAKS.groovy"
click node_deploy_environment "https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/sectionDeployToEnvironment.groovy"
click node_promote "https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/sectionPromoteBuildToStage.groovy"
click node_infra_build "https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/sectionInfraBuild.groovy"
click node_infra_shared "https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/sharedInfrastructurePipeline.groovy"
click node_environment_agent "https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/withEnvironmentAgent.groovy"
click node_subscription "https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/withSubscription.groovy"
click node_security "https://github.com/hmcts/cnp-jenkins-library/blob/master/src/uk/gov/hmcts/contino/SecurityScan.groovy"
click node_fortify "https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/fortifyScan.groovy"
click node_pact "https://github.com/hmcts/cnp-jenkins-library/blob/master/src/uk/gov/hmcts/contino/PactBroker.groovy"
click node_performance "https://github.com/hmcts/cnp-jenkins-library/blob/master/src/uk/gov/hmcts/contino/Gatling.groovy"
click node_dynatrace "https://github.com/hmcts/cnp-jenkins-library/blob/master/src/uk/gov/hmcts/contino/DynatraceClient.groovy"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_pipeline,node_infra_pipeline,node_nightly_pipeline toneBlue
class node_build_test,node_docker,node_deploy_aks,node_deploy_environment,node_promote toneAmber
class node_infra_build,node_infra_shared,node_environment_agent,node_subscription toneMint
class node_security,node_fortify,node_pact,node_performance,node_dynatrace toneRose
class node_jenkins toneIndigo
```

## Components

### Pipeline entry points

- [App pipeline](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/withPipeline.groovy): `vars/withPipeline.groovy`
- [Infrastructure pipeline](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/withInfraPipeline.groovy): `vars/withInfraPipeline.groovy`
- [Nightly pipeline](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/withNightlyPipeline.groovy): `vars/withNightlyPipeline.groovy`

### Application delivery

- [Build and test](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/sectionBuildAndTest.groovy): `vars/sectionBuildAndTest.groovy`
- [Docker build](https://github.com/hmcts/cnp-jenkins-library/blob/master/src/uk/gov/hmcts/contino/Docker.groovy): `src/uk/gov/hmcts/contino/Docker.groovy`
- [AKS deployment](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/sectionDeployToAKS.groovy): `vars/sectionDeployToAKS.groovy`
- [Environment deployment](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/sectionDeployToEnvironment.groovy): `vars/sectionDeployToEnvironment.groovy`
- [Build promotion](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/sectionPromoteBuildToStage.groovy): `vars/sectionPromoteBuildToStage.groovy`

### Infrastructure delivery

- [Infrastructure build](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/sectionInfraBuild.groovy): `vars/sectionInfraBuild.groovy`
- [Shared infrastructure](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/sharedInfrastructurePipeline.groovy): `vars/sharedInfrastructurePipeline.groovy`
- [Environment agents](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/withEnvironmentAgent.groovy): `vars/withEnvironmentAgent.groovy`
- [Subscription access](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/withSubscription.groovy): `vars/withSubscription.groovy`

### Quality and integrations

- [Security checks](https://github.com/hmcts/cnp-jenkins-library/blob/master/src/uk/gov/hmcts/contino/SecurityScan.groovy): `src/uk/gov/hmcts/contino/SecurityScan.groovy`
- [Fortify scanning](https://github.com/hmcts/cnp-jenkins-library/blob/master/vars/fortifyScan.groovy): `vars/fortifyScan.groovy`
- [Pact testing](https://github.com/hmcts/cnp-jenkins-library/blob/master/src/uk/gov/hmcts/contino/PactBroker.groovy): `src/uk/gov/hmcts/contino/PactBroker.groovy`
- [Performance testing](https://github.com/hmcts/cnp-jenkins-library/blob/master/src/uk/gov/hmcts/contino/Gatling.groovy): `src/uk/gov/hmcts/contino/Gatling.groovy`
- [Dynatrace testing](https://github.com/hmcts/cnp-jenkins-library/blob/master/src/uk/gov/hmcts/contino/DynatraceClient.groovy): `src/uk/gov/hmcts/contino/DynatraceClient.groovy`

### Other components

- **Jenkins consumer**

## Connections

- Jenkins consumer → App pipeline: loads library (evidence: `README.md`)
- Jenkins consumer → Infrastructure pipeline: loads library (evidence: `README.md`)
- Jenkins consumer → Nightly pipeline: loads library (evidence: `README.md`)
- App pipeline → Build and test: runs stages (evidence: `README.md`)
- App pipeline → Security checks: runs checks (evidence: `README.md`)
- App pipeline → Docker build: builds image (evidence: `README.md`)
- App pipeline → AKS deployment: deploys to AKS (evidence: `README.md`)
- App pipeline → Environment deployment: deploys environment (evidence: `README.md`)
- App pipeline → Build promotion: promotes build (evidence: `README.md`)
- Infrastructure pipeline → Infrastructure build: runs stages (evidence: `README.md`)
- Infrastructure pipeline → Shared infrastructure: supports infrastructure (evidence: `README.md`)
- App pipeline → Environment agents: uses scoped agents (evidence: `README.md`)
- Infrastructure pipeline → Environment agents: uses scoped agents (evidence: `README.md`)
- Jenkins consumer → Subscription access: runs block (evidence: `README.md`)
- Nightly pipeline → Performance testing: supports performance tests (evidence: `README.md`)
- Nightly pipeline → Dynatrace testing: supports performance tests (evidence: `README.md`)
- App pipeline → Pact testing: supports contract tests (evidence: `README.md`)
- App pipeline → Fortify scanning: supports security scans (evidence: `README.md`)
