Jenkins Build Configuration (jenkins.yaml)
JSON Schemas
jenkins.yaml Jenkins configuration files can be validated with their respective JSON schemas. There is one JSON schema
defined per project "type" (service (default), web, mock, library), however, all schemas besides the library
schema are equivalent.
They are uniquely named to map directly from the project type to its schema, and also to support if their definitions diverge. However, this is not foreseen nor planned.
Currently, there is one version of these schemas - v1. Updates to the Jenkins configuration file formats will occur
sparingly, prioritizing both backward and forward compatibility to the fullest extent feasible. This means, while
there may be new optional fields and/or minor changes to the file format, there will not be many breaking changes or
renaming of fields.
Default Values
Jenkins Shared Library provides reasonable defaults for fields that likely will not need to be changed, project-to-project. These values are specified in YAML files specific to each project type:
| Project Type | Default YAML File |
|---|---|
|
|
|
|
|
|
|
When reading the project’s jenkins.yaml configuration file, the values set in the corresponding default YAML file are
applied first, then each field specified in the project jenkins.yaml overrides the default value.
Default YAML File Contents
Service Project Defaults
#image: "/ces/cerner-fhir-adapter"
language: java
buildTool: skaffold-maven # skaffold-maven, helm-maven
imageTool: skaffold # skaffold, jib, docker
moduleDir: . # service module directory. If not a multi-module project, use '.'
mavenBuildCommand: mvn install
enableVV: true
enableSonar: true
sonarMainBranchOnly: false
enableQualityGate: true
#sonarReportUrl: 'coderepo.mobilehealth.va.gov/scm/ckm/quality-reports.git'
sonarReportBranch: 'master'
enableManualDeploy: false
enableAutoDeploy: false
enableSlackNotifications: false
slackChannel: ckmbuild
#vvReportUrl: 'coderepo.mobilehealth.va.gov/scm/ckm/vv-reports.git'
publishSnapshots: false
checkImageExists: false
cacheKeyEnabled: false
#jiraProject: CKM
enableOisScan: true
#oisScanCron: '@weekly' # removed in favor of value returned by OIS library
branchesOisScanRegex: '.*'
deferCodeQLInit: false
buildCommandForCodeQL: 'mvn clean install --batch-mode -Dmaven.test.skip -Dmaven.javadoc.skip=true -DskipAll -Dexec.skip=true -Dhelm.skip -Ddocker.skip -Djib.skip -Djacoco.skip=true -Djacoco.dump.skip=true -Pjenkins,jenkins-sandbox,skip-static-analysis'
runNewman: false
enableTagRelease: false
runK6: false
enableFlexline: false
mavenDeployOptsRelease: '-DaltDeploymentRepository=ckm-releases::default::https://nexus.mobilehealth.va.gov/content/repositories/ckm-releases'
mavenDeployOptsSnapshot: '-DaltDeploymentRepository=ckm-snapshots::default::https://nexus.mobilehealth.va.gov/content/repositories/ckm-snapshots'
sandbox:
periodicBuild:
branch: main
cron: '@weekly'
branchesToPushImageRegex: '(?i)(release/.*)'
deployNamespace: default
deferCodeQLInit: true
ignoreFlexlineFailure: false
staging: # staging/sqa build environment overrides
enableAutoDeploy: true
enableManualDeploy: true
deployNamespace: sqa
enableSlackNotifications: true
checkImageExists: true
slackFailureChannel: ckmbuildfailures
branchesToPushImageRegex: '(?i)release/.+'
deferCodeQLInit: true
prod: # prod build environment overrides
skip: true
deployStageOnly: true # disables all but deploy stage
deployNamespace: prod
enableAutoDeploy: false
enableManualDeploy: true
Web Project Defaults
#image: "/ces/cerner-fhir-adapter"
language: java
buildTool: skaffold-maven # skaffold-maven, helm-maven
imageTool: skaffold # skaffold, jib, docker
moduleDir: . # service module directory. If not a multi-module project, use '.'
mavenBuildCommand: mvn install
enableVV: true
enableSonar: true
sonarMainBranchOnly: false
enableQualityGate: true
#sonarReportUrl: 'coderepo.mobilehealth.va.gov/scm/ckm/quality-reports.git'
sonarReportBranch: 'master'
enableManualDeploy: false
enableAutoDeploy: false
enableSlackNotifications: false
slackChannel: ckmbuild
#vvReportUrl: 'coderepo.mobilehealth.va.gov/scm/ckm/vv-reports.git'
publishSnapshots: false
checkImageExists: false
cacheKeyEnabled: false
#jiraProject: CKM
enableOisScan: true
#oisScanCron: '@weekly' # removed in favor of value returned by OIS library
branchesOisScanRegex: '(?i)(release/.*)'
deferCodeQLInit: false
buildCommandForCodeQL: 'mvn clean install --batch-mode -Dmaven.test.skip -DskipAll -Dhelm.skip -Ddocker.skip -Djib.skip -Djacoco.skip=true -Djacoco.dump.skip=true -Pjenkins,jenkins-sandbox'
enableTagRelease: false
enableFlexline: false
mavenDeployOptsRelease: '-DaltDeploymentRepository=ckm-releases::default::https://nexus.mobilehealth.va.gov/content/repositories/ckm-releases'
mavenDeployOptsSnapshot: '-DaltDeploymentRepository=ckm-snapshots::default::https://nexus.mobilehealth.va.gov/content/repositories/ckm-snapshots'
sandbox:
periodicBuild:
branch: main
cron: '@weekly'
branchesToPushImageRegex: '(?i)(release/.*)'
deployNamespace: default
ignoreFlexlineFailure: false
staging: # staging/sqa build environment overrides
enableAutoDeploy: true
enableManualDeploy: true
deployNamespace: sqa
enableSlackNotifications: true
checkImageExists: true
slackFailureChannel: ckmbuildfailures
branchesToPushImageRegex: '(?i)release/.+'
deferCodeQLInit: true
prod: # prod build environment overrides
skip: true
deployStageOnly: true # disables all but deploy stage
deployNamespace: prod
enableAutoDeploy: false
enableManualDeploy: true
Mock Project Defaults
#image: "/ces/cerner-fhir-adapter"
language: java
buildTool: skaffold-maven # skaffold-maven, helm-maven
imageTool: skaffold # skaffold, jib, docker
moduleDir: . # service module directory. If not a multi-module project, use '.'
mavenBuildCommand: mvn install
enableVV: false
enableSonar: false
sonarMainBranchOnly: false
enableQualityGate: true
#sonarReportUrl: 'coderepo.mobilehealth.va.gov/scm/ckm/quality-reports.git'
sonarReportBranch: 'master'
enableManualDeploy: false
enableAutoDeploy: false
enableSlackNotifications: false
slackChannel: ckmbuild
#vvReportUrl: 'coderepo.mobilehealth.va.gov/scm/ckm/vv-reports.git'
publishSnapshots: false
checkImageExists: false
cacheKeyEnabled: false
#jiraProject: CKM
enableOisScan: false
mavenDeployOptsRelease: '-DaltDeploymentRepository=ckm-releases::default::https://nexus.mobilehealth.va.gov/content/repositories/ckm-releases'
mavenDeployOptsSnapshot: '-DaltDeploymentRepository=ckm-snapshots::default::https://nexus.mobilehealth.va.gov/content/repositories/ckm-snapshots'
deferCodeQLInit: false
buildCommandForCodeQL: 'mvn clean install --batch-mode -Dmaven.test.skip -DskipAll -Dhelm.skip -Ddocker.skip -Djib.skip -Djacoco.skip=true -Djacoco.dump.skip=true -Pjenkins,jenkins-sandbox'
enableTagRelease: false
enableFlexline: false
sandbox:
periodicBuild:
branch: main
cron: '@weekly'
branchesToPushImageRegex: '(?i)(release/.*)'
deployNamespace: default
ignoreFlexlineFailure: false
staging: # staging/sqa build environment overrides
enableSlackNotifications: true
checkImageExists: true
slackFailureChannel: ckmbuildfailures
branchesToPushImageRegex: '(?i)release/.+'
deferCodeQLInit: true
prod: # prod build environment overrides
skip: true
Library Project Defaults
publishSnapshots: false
enableOisScan: false
enableFlexline: false
mavenDeployOptsRelease: '-DaltDeploymentRepository=ckm-releases::default::https://nexus.mobilehealth.va.gov/content/repositories/ckm-releases'
mavenDeployOptsSnapshot: '-DaltDeploymentRepository=ckm-snapshots::default::https://nexus.mobilehealth.va.gov/content/repositories/ckm-snapshots'
deferCodeQLInit: false
periodicBuild:
branch: main
cron: '@weekly'
Environment Defaults and Overrides
The fields sandbox, staging, and prod correspond to the three environments that the project is built with Jenkins.
These objects have the same fields available as the "root" level fields (except, of course, themselves), and are used to
specify any field values that are specific to that build environment. If there is no override value specified, then the
environment-specific build will use the root-level (or default) value.
enableQualityGate: false (1)
sandbox:
enableQualityGate: true
staging:
# enableQualityGate: false (2)
| 1 | Project "root"-level value
Default values specified within each environment block take precedence over the "root"-level project values. In order to
override these values, the project jenkins.yaml must set the value within the environment block. |
| 2 | The effective value is false and doesn’t need to be set here because the root/default value is already false and there is no environment-specific default set |
For example, given the default staging enableSlackNotifications value of true:
jenkins-default.yamlstaging:
enableSlackNotifications: true
jenkins.yamlenableSlackNotifications: false (1)
# ...
staging:
enableSlackNotifications: false (2)
| 1 | Values at the root level override default root-level values, but not environment-level ones |
| 2 | The only way to override default environment-level values is to specify within the environment’s specification |
Service, Web, and Mock Project Fields
Following are tables that describe all available and required fields in the jenkins.yaml file.
Required fields
| Name | Type | Description | Example |
|---|---|---|---|
|
string |
Service container image name |
|
|
string |
(Required if Sonar is enabled) Git repository to store Sonar reports |
|
|
string |
(Required if V&V is enabled) Git repository to store V&V reports |
|
|
string |
(Required if |
|
Optional fields
| Name | Type | Description | Default Value |
|---|---|---|---|
|
string |
Maven artifact ID |
|
|
string |
Maven group ID |
|
|
string |
Project version |
|
|
enum |
|
|
|
enum |
|
|
|
enum |
|
|
|
string |
Relative file path from project directory to Maven service module (working directory) |
|
|
string |
Maven command to build service |
|
|
boolean |
Enable V&V stage and build/report options |
|
|
boolean |
Enable Sonar stage and build/report options |
|
|
boolean |
Only publish Sonar reports on |
|
|
string |
The branch of the Sonar reports repo to edit |
|
|
boolean |
Enable Sonar quality gate |
|
|
boolean |
Enable manual Jenkins job-based deployment to Kubernetes cluster |
|
|
boolean |
Enable auto-deployment post-build to Kubernetes cluster |
|
|
boolean |
Enable Slack notifications to be sent on build actions and results |
|
|
string |
Slack channel to publish notifications |
|
|
boolean |
Enable publshing of Maven snapshot builds to snapshot repository |
|
|
boolean |
Enable pre-build check for the existence of same image in the DTR |
|
|
boolean |
Enable dependence on Caché key |
|
|
string |
JIRA component name |
|
|
boolean |
Enable OIS scan capability |
|
|
regex |
Regular expression of branches to run OIS scan on |
|
|
boolean |
Run additional trace build using the command supplied in |
|
|
string |
Command to run when |
|
|
string |
Maven options to include in the post-build |
|
|
string |
Maven options to include in the post-build |
|
|
object |
Schedule periodic builds of service |
|
|
boolean |
Push images from all branches to the DTR |
|
|
regex |
Regular expression of branches to push the image to the DTR |
|
|
boolean |
Only include the Deploy stage in the build definition |
|
|
string |
The Kubernetes namespace to deploy the application to for manual and automatic deployments |
|
|
string |
(Service only) Command to run after deployment completes |
|
|
string |
The Slack channel to send messages to on build failures |
|
|
boolean |
Completely skip build of service |
|
|
boolean |
(Service only) Enable Newman (Postman) test execution |
|
|
boolean |
(Service only) Enable k6 performance test execution |
|
|
boolean |
Enable tagging of releases |
|
|
boolean |
Enable Flexline integration |
|
|
array |
Define project-specific build parameters to be used as environment variables |
|
|
object |
Values in the Sandbox environment to override |
|
|
object |
Values in the Staging/SQA environment to override |
|
|
object |
Values in the Production environment to override |
|
Periodic Build Type
The periodicBuild field is a complex object that specifies automatic scheduled builds using cron-style syntax.
The following fields are valid for this object:
| Name | Type | Description |
|---|---|---|
|
string |
The Git branch to schedule builds for |
|
string |
The cron-formatted value that defines when to build. See https://www.cloudbees.com/blog/how-to-schedule-a-jenkins-job. |
Custom Parameters
The customParameters field is an array of items which have the following structure:
| Name | Type | Description |
|---|---|---|
|
string |
The name of the build parameter |
|
enum [ |
The type of Jenkins build parameter |
|
string |
Description of the parameter that is displayed in the Jenkins build UI alongside the parameter |
|
string or boolean |
The default value of the build parameter, unless set via |
|
string |
The |
|
string |
When this is present, an environment variable with this name is set to the provided value |
Environment Default Values
Following are the default values for each environment for the service project type:
sandbox:
periodicBuild:
branch: main
cron: '@weekly'
branchesToPushImageRegex: '(?i)(release/.*)'
deployNamespace: default
staging: # staging/sqa build environment overrides
enableAutoDeploy: true
enableManualDeploy: true
deployNamespace: sqa
enableSlackNotifications: true
checkImageExists: true
slackFailureChannel: ckmbuildfailures
branchesToPushImageRegex: '(?i)release/.+'
deferCodeQLInit: true
prod: # prod build environment overrides
skip: true
deployStageOnly: true # disables all but deploy stage
enableAutoDeploy: false
enableManualDeploy: true