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 |
---|
Example to call two Ant targets:
builders:
- ant: "target1 target2"
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: "base-build"
Change the assembly version. Requires the Jenkins Change Assembly Version.
Parameters: |
|
---|
Example:
builders:
- change-assembly-version:
version: "1.2.3"
assembly-file: "AFile"
Conditionally 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: current-status
condition-worst: SUCCESS
condition-best: FAILURE
steps:
- shell: "sl"
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"
optional: true
flatten: true
parameter-filters: PUBLISH=true
Designate the end of a critical block. Must be used in conjuction with critical-block-start.
Must also add a build wrapper (exclusion), specifying the resources that control the critical block. Otherwise, this will have no effect.
Requires Jenkins Exclusion Plugin.
Example:
wrappers:
- exclusion:
resources:
myresource1
builders:
- critical-block-start
- ... other builders
- critical-block-end
Designate the start of a critical block. Must be used in conjuction with critical-block-end.
Must also add a build wrapper (exclusion), specifying the resources that control the critical block. Otherwise, this will have no effect.
Requires Jenkins Exclusion Plugin.
Example:
wrappers:
- exclusion:
resources:
myresource1
builders:
- critical-block-start
- ... other builders
- critical-block-end
Execute gradle tasks. Requires the Jenkins Gradle Plugin.
Parameters: |
|
---|
Example:
builders:
- gradle:
gradle-name: "gradle-1.2"
wrapper: true
executable: true
use-root-dir: true
root-build-script-dir: ${workspace}/tests
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"
Execute a groovy script or command. Requires the Jenkins Groovy Plugin
Parameters: |
|
---|
Examples:
builders:
- groovy:
file: "test.groovy"
builders:
- groovy:
command: "Some command"
version: "Groovy 1.2"
parameters: "parameters"
script-parameters: "script parameters"
properties: "properties"
java-opts: "java opts"
Inject an environment for the job. Requires the Jenkins EnvInject Plugin.
Parameters: |
|
---|
Example:
builders:
- inject:
properties-file: example.prop
properties-content: EXAMPLE=foo-bar
This step allows to reference and execute a centrally managed script within your build. Requires the Jenkins Managed Script Plugin.
Parameters: |
|
---|
Example:
builders:
- managed-script:
script-id: org.jenkinsci.plugins.managedscripts.ScriptConfig1401886156431
type: script
args:
- arg1
- arg2
builders:
- managed-script:
script-id: org.jenkinsci.plugins.managedscripts.WinBatchConfig1402391729132
type: batch
args:
- arg1
- arg2
Execute top-level Maven targets
Parameters: |
|
---|
Example:
builders:
- maven-target:
maven-version: Maven3
pom: parent/pom.xml
goals: clean
private-repository: true
properties:
- foo=bar
- bar=foo
java-opts:
- "-Xms512m -Xmx1024m"
- "-XX:PermSize=128m -XX:MaxPermSize=256m"
settings: mvn/settings.xml
global-settings: mvn/globalsettings.xml
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
node-label-name: "vm_name"
node-label: "agent-${BUILD_NUMBER}"
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
kill-phase-on: UNSTABLE
Execute a powershell command. Requires the Powershell Plugin.
Parameter: | the powershell command to execute |
---|
Example:
builders:
- powershell: "foo/foo.ps1"
Execute a python command. Requires the Jenkins Python plugin.
Parameters: | parameter (str) – the python command to execute |
---|
Example:
builders:
- python: 'import foobar'
Execute a sbt build step. Requires the Jenkins Sbt Plugin.
Parameters: |
|
---|
Example:
builders:
- sbt:
name: "default"
actions: "clean package"
jvm-flags: "-Xmx8G"
Execute a shell command.
Parameters: | parameter (str) – the shell command to execute |
---|
Example:
builders:
- shell: "make test"
Execute a command inside various python environments. Requires the Jenkins ShiningPanda plugin.
Parameters: | build-environment (str) – Building environment to set up (Required).
|
---|
For the python environment
Parameters: | python-version (str) – Name of the python installation to use. Must match one of the configured installations on server configuration (default: System-CPython-2.7) |
---|
For the custom environment:
Parameters: | home (str) – path to the home folder of the custom installation (Required) |
---|
For the virtualenv environment:
Parameters: |
|
---|
Common to all environments:
Parameters: |
|
---|
Examples:
builders:
- shining-panda:
build-environment: python
python-version: System-CPython-2.7
nature: python
command: setup.py build
ignore-exit-code: false
builders:
- shining-panda:
build-environment: custom
home: /usr/local/lib/custom-python-27
nature: xshell
command: |
cd $HOME/build
python setup.py build
ignore-exit-code: true
builders:
- shining-panda:
build-environment: virtualenv
python-version: System-CPython-2.7
nature: shell
command: python setup.py build
name: virtvenv1
clear: true
use-distribute: true
system-site-packages: true
ignore-exit-code: true
Send files or execute commands over SSH. Requires the Jenkins Publish over SSH Plugin.
Parameters: |
|
---|
Example:
builders:
- ssh:
site: 'server.example.com'
target: 'dest/dir'
source: 'base/source/dir/**'
remove-prefix: 'base/source/dir'
excludes: '**/*.excludedfiletype'
use-pty: true
command: 'rm -r jenkins_$BUILD_NUMBER'
timeout: 1800000
Execute a system groovy script or command. Requires the Jenkins Groovy Plugin
Parameters: |
|
---|
Examples:
builders:
- system-groovy:
file: "test.groovy"
builders:
- system-groovy:
command: "Some command"
bindings: "Some bindings"
class-path: "Some classpath"
Trigger builds of other jobs. Requires the Jenkins Parameterized Trigger Plugin.
Parameters: |
|
---|
Examples:
Basic usage.
builders:
- trigger-builds:
- project: "build_started"
predefined-parameters:
FOO="bar"
current-parameters: true
svn-revision: true
block: true
Example with all supported parameter factories.
builders:
- trigger-builds:
- project: "build_started"
predefined-parameters:
FOO="bar"
current-parameters: true
svn-revision: true
parameter-factories:
- factory: filebuild
file-pattern: propfile*.txt
- factory: binaryfile
parameter-name: filename
file-pattern: otherpropfile*.txt
- factory: counterbuild
from: 0
to: 5
step: 1
block: true