Skip to content

buildExecute

Description

This step serves as generic entry point in pipelines for building artifacts.

You can use pre-defined buildTools.

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 buildTools the artifact will just be stored in the workspace and could then be stashed for later use.

Prerequisites

When performing a Docker build you need to maintain the respective credentials in your Jenkins credentials store.
Further details

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 the buildTool.
  • 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 the dockerImage 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 container
  • dockerImageName - 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 like https://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 tool
  • npmInstall - For buildTool npm: Execute npm install (boolean, default 'true')
  • npmRunScripts - For buildTool npm: List of npm run scripts to execute
  • script - The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the this parameter, as in script: this. This allows the function to access the commonPipelineEnvironment 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

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.