buildExecute¶
Description¶
This step serves as generic entry point in pipelines for building artifacts.
You can use pre-defined buildTool
s.
Alternatively you can define a command via dockerCommand
which should be executed in dockerImage
.
This allows you to trigger any build tool using a defined Docker container which provides the required build infrastructure.
When using buildTool: docker
or buildTool: kaniko
the created container image is uploaded to a container registry.
You need to make sure that the required credentials are provided to the step.
For all other buildTool
s the artifact will just be stored in the workspace and could then be stash
ed for later use.
Prerequisites¶
When performing a Docker build you need to maintain the respective credentials in your Jenkins credentials store.
Further details
- for builds when a Docker deamon: see step containerPushToRegistry
- for builds using Kaniko: see step kanikoExecute
Example¶
buildExecute script:this, buildTool: 'maven'
Parameters¶
name | mandatory | default | possible values |
---|---|---|---|
buildTool |
no | docker , kaniko , maven , mta , npm |
|
cnbBuild |
no | ||
containerBuildOptions |
no | ||
dockerCommand |
no | ||
dockerImage |
no | ||
dockerImageName |
no | ||
dockerImageTag |
no | ||
dockerRegistryUrl |
no | ||
helmExecute |
no | ||
npmInstall |
no | true |
|
npmRunScripts |
no | [] |
|
script |
yes |
buildTool
- Defines the tool used for the build.cnbBuild
- Defines if a container image(s) should be created with Cloud Native Buildpacks using the artifact produced by thebuildTool
.containerBuildOptions
- Only for Docker builds on the local daemon: Defines the build options for the build.dockerCommand
- For custom build types: Defines the command to be executed within thedockerImage
in order to execute the build.dockerImage
- For custom build types: Image to be used for builds in case they should run inside a custom Docker containerdockerImageName
- For Docker builds only (mandatory): name of the image to be built.dockerImageTag
- For Docker builds only (mandatory): tag of the image to be built.dockerRegistryUrl
- For Docker builds only: Defines the registry url where the image should be pushed to, incl. the protocol likehttps://my.registry.com
. If it is not defined, image will not be pushed to a registry.helmExecute
- toggles if a helmExecute is triggered at end of the step after invoking the build toolnpmInstall
- For buildTool npm: Execute npm install (boolean, default 'true')npmRunScripts
- For buildTool npm: List of npm run scripts to executescript
- The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with thethis
parameter, as inscript: this
. This allows the function to access thecommonPipelineEnvironment
for retrieving, e.g. configuration parameters.
Step configuration¶
We recommend to define values of step parameters via config.yml file.
In following sections of the config.yml the configuration is possible:
parameter | general | step/stage |
---|---|---|
buildTool |
X | X |
cnbBuild |
X | |
containerBuildOptions |
X | |
dockerCommand |
X | |
dockerImage |
X | |
dockerImageName |
X | X |
dockerImageTag |
X | |
dockerRegistryUrl |
X | X |
helmExecute |
X | |
npmInstall |
X | |
npmRunScripts |
X | |
script |
Dependencies¶
The step depends on the following Jenkins plugins
- docker
- kubernetes
- pipeline-utility-steps
- workflow-basic-steps
- workflow-cps-global-lib
- workflow-durable-task-step
The kubernetes plugin is only used if running in a kubernetes environment. Transitive dependencies are omitted.
The list might be incomplete.
Consider using the ppiper/jenkins-master docker image. This images comes with preinstalled plugins.