Builders define actions that the Jenkins job should execute. Examples include shell scripts or maven targets. The builders attribute in the Job definition accepts a list of builders to invoke. They may be components defined below, locally defined macros (using the top level definition of builder:, or locally defined components found via the jenkins_jobs.builders entry point.
Macro: | builder |
---|---|
Entry Point: | jenkins_jobs.builders |
Example:
job:
name: test_job
builders:
- shell: "make test"
Execute an ant target. Requires the Jenkins Ant Plugin.
To setup this builder you can either reference the list of targets or use named parameters. Below is a description of both forms:
1) Listing targets:
After the ant directive, simply pass as argument a space separated list of targets to build.
Parameter : | space separated list of Ant targets |
---|---|
Parameters: | ant-name (str) – the name of the ant installation, defaults to ‘default’ (optional) |
Example to call two Ant targets:
builders:
- ant: "target1 target2"
ant-name: "Standard Ant"
The build file would be whatever the Jenkins Ant Plugin is set to use per default (i.e build.xml in the workspace root).
2) Using named parameters:
Parameters: |
|
---|
Example specifying the build file too and several targets:
builders:
- ant:
targets: "debug test install"
buildfile: "build.xml"
properties:
builddir: "/tmp/"
failonerror: true
java-opts:
- "-ea"
- "-Xmx512m"
ant-name: "Standard Ant"
Allows one to resolve artifacts from a maven repository like nexus (without having maven installed) Requires the Jenkins Repository Connector Plugin
Parameters: |
|
---|
Example:
builders:
- artifact-resolver:
fail-on-error: true
repository-logging: true
target-directory: foo
artifacts:
- group-id: commons-logging
artifact-id: commons-logging
version: 1.1
classifier: src
extension: jar
target-file-name: comm-log.jar
- group-id: commons-lang
artifact-id: commons-lang
version: 1.2
Execute a batch command.
Parameter : | the batch command to execute |
---|
Example:
builders:
- batch: "foo/foo.bat"
Use builders from another project. Requires the Jenkins Template Project Plugin.
Parameters: | projectName (str) – the name of the other project |
---|
Example:
builders:
- builders-from:
- project: "base-build"
Conditionaly execute some build steps. Requires the Jenkins Conditional BuildStep Plugin.
Depending on the number of declared steps, a Conditional step (single) or a Conditional steps (multiple) is created in Jenkins.
Parameters: |
|
---|
Condition kind | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
always | Condition is always verified | ||||||||
never | Condition is never verified | ||||||||
boolean-expression | Run the step if the expression expends to a representation of true
|
||||||||
current-status | Run the build step if the current build status is within the configured range
|
||||||||
shell | Run the step if the shell command succeed
|
||||||||
windows-shell | Similar to shell, except that commands will be executed by cmd, under Windows
|
||||||||
file-exists | Run the step if a file exists
|
Example:
builders:
- conditional-step:
condition-kind: boolean-expression
condition-expression: "${ENV,var=IS_STABLE_BRANCH}"
on-evaluation-failure: mark-unstable
steps:
- shell: "echo Making extra checks"
Copy artifact from another project. Requires the Jenkins Copy Artifact plugin.
Parameters: |
|
---|---|
Which-build values: | |
|
|
Permalink values: | |
|
Example:
builders:
- copyartifact:
project: foo
filter: *.tar.gz
target: /home/foo
which-build: specific-build
build-number: 123
flatten: true
Execute gradle tasks. Requires the Jenkins Gradle Plugin.
Parameters: |
|
---|
Example:
builders:
- gradle:
gradle-name: "gradle-1.2"
wrapper: true
executable: true
switches:
- "-g /foo/bar/.gradle"
- "-PmavenUserName=foobar"
tasks: |
init
build
tests
Execute a grails build step. Requires the Jenkins Grails Plugin.
Parameters: |
|
---|
Example:
builders:
- grails:
use-wrapper: "true"
name: "grails-2.2.2"
force-upgrade: "true"
non-interactive: "true"
targets: "war ear"
server-port: "8003"
work-dir: "./grails-work"
project-dir: "./project-work"
base-dir: "./grails/project"
properties: "program.name=foo"
plain-output: "true"
stack-trace: "true"
verbose: "true"
refresh-dependencies: "true"
Inject an environment for the job. Requires the Jenkins EnvInject Plugin.
Parameters: |
|
---|
Example:
builders:
- inject:
properties-file: example.prop
properties-content: EXAMPLE=foo-bar
Execute top-level Maven targets
Parameters: |
|
---|
Example:
builders:
- maven-target:
maven-version: Maven3
pom: parent/pom.xml
goals: clean
properties:
- foo=bar
- bar=foo
Build .NET project using msbuild. Requires the Jenkins MSBuild Plugin.
Parameters: |
|
---|
Example:
builders:
- msbuild:
solution-file: "MySolution.sln"
msbuild-version: "msbuild-4.0"
extra-parameters: "/maxcpucount:4"
pass-build-variables: False
continue-on-build-failure: True
Define a multijob phase. Requires the Jenkins Multijob Plugin.
This builder may only be used in jenkins_jobs.modules.project_multijob.MultiJob projects.
Parameters: |
|
---|
Example:
builders:
- multijob:
name: PhaseOne
condition: SUCCESSFUL
projects:
- name: PhaseOneJobA
current-parameters: true
git-revision: true
- name: PhaseOneJobB
current-parameters: true
property-file: build.props
- multijob:
name: PhaseTwo
condition: UNSTABLE
projects:
- name: PhaseTwoJobA
current-parameters: true
predefined-parameters: foo=bar
- name: PhaseTwoJobB
current-parameters: false
Execute a shell command.
Parameter : | the shell command to execute |
---|
Example:
builders:
- shell: "make test"
Trigger builds of other jobs. Requires the Jenkins Parameterized Trigger Plugin.
Parameters: |
|
---|
Example:
builders:
- trigger-builds:
- project: "build_started"
predefined-parameters:
FOO="bar"
block: true