2.7 KiB
${docGenStepName}
${docGenDescription}
see Examples
Prerequisites
When pushing to a container registry, you need to maintain the respective credentials in your Jenkins credentials store:
cnbBuild
expects a Docker config.json
file containing the credential information for registries.
You can create it like explained in the protocodeExecuteScan Prerequisites section.
Please copy this file and upload it to your Jenkins for example
via Jenkins -> Credentials -> System -> Global credentials (unrestricted) -> Add Credentials ->
- Kind: Secret file
- File: upload your
config.json
file - ID: specify id which you then use for the configuration of
dockerConfigJsonCredentialsId
(see below)
${docGenParameters}
Additional hints
To run the cnbBuild
with a different builder, you can specify the dockerImage
parameter.
Without specifying it, the step will run with the paketobuildpacks/builder:base
builder.
Default Excludes
When building images, these files/folders are excluded from the build by default:
- Piper binary:
piper
- Piper configuration folder:
.pipeline
- Git folder:
.git
This behavior can be overwritten by using the respective sections in project.toml
. Keep in mind that by doing so, no default excludes will be applied by the cnbBuild
step at all.
${docGenConfiguration}
${docJenkinsPluginDependencies}
Examples
Example 1: simple usage
cnbBuild(
script: this,
dockerConfigJsonCredentialsId: 'DOCKER_REGISTRY_CREDS',
containerImageName: 'images/example',
containerImageTag: 'v0.0.1',
containerRegistryUrl: 'gcr.io'
)
Example 2: User provided builder
cnbBuild(
script: this,
dockerConfigJsonCredentialsId: 'DOCKER_REGISTRY_CREDS',
dockerImage: 'paketobuildpacks/builder:base',
containerImageName: 'images/example',
containerImageTag: 'v0.0.1',
containerRegistryUrl: 'gcr.io'
)
Example 3: User provided buildpacks
cnbBuild(
script: this,
dockerConfigJsonCredentialsId: 'DOCKER_REGISTRY_CREDS',
containerImageName: 'images/example',
containerImageTag: 'v0.0.1',
containerRegistryUrl: 'gcr.io',
buildpacks: ['gcr.io/paketo-buildpacks/nodejs', 'paketo-community/build-plan']
)
Example 4: Build environment variables
cnbBuild(
script: this,
dockerConfigJsonCredentialsId: 'DOCKER_REGISTRY_CREDS',
containerImageName: 'images/example',
containerImageTag: 'v0.0.1',
containerRegistryUrl: 'gcr.io',
buildEnvVars: [
"FOO": "BAR"
]
)