table of contents
other versions
- jessie 0.9.0-0.2
- testing 2.9.1-1
- stretch-backports 2.9.1-1~bpo9+1
- unstable 2.9.1-1
JENKINS-JOBS(1) | Jenkins Job Builder | JENKINS-JOBS(1) |
NAME¶
jenkins-jobs - Jenkins Job Builder Documentation Jenkins Job Builder takes simple descriptions of Jenkins jobs in YAML format, and uses them to configure Jenkins. You can keep your job descriptions in human readable text format in a version control system to make changes and auditing easier. It also has a flexible template system, so creating many similarly configured jobs is easy. Contents:INSTALLATION¶
To install Jenkins Job Builder, run:sudo python setup.py install
The OpenStack project uses Puppet to manage its infrastructure systems, including Jenkins. If you use Puppet, you can use the OpenStack Jenkins module to install Jenkins Job Builder.
Documentation¶
Documentation is included in the doc folder. To generate docs locally execute the command:tox -e doc
The generated documentation is then available under doc/build/html/index.html.
Unit Tests¶
Unit tests have been included and are in the tests folder. We recently started including unit tests as examples in our documentation so to keep the examples up to date it is very important that we include unit tests for every module. To run the unit tests, execute the command:tox -e py27
- •
- Note: View tox.ini to run tests on other versions of Python.
Test Coverage¶
To measure test coverage, execute the command:tox -e cover
Configuration File¶
After installation, you will need to create a configuration file. By default, jenkins-jobs looks in /etc/jenkins_jobs/jenkins_jobs.ini but you may specify an alternative location when running jenkins-jobs. The file should have the following format:[job_builder] ignore_cache=True keep_descriptions=False include_path=.:scripts:~/git/ recursive=False [jenkins] user=jenkins password=1234567890abcdef1234567890abcdef url=https://jenkins.example.com ##### This is deprecated, use job_builder section instead #ignore_cache=True
job_builder section¶
- ignore_cache
- (Optional) If set to True, Jenkins Job Builder won't use any cache.
- keep_descriptions
- By default jenkins-jobs will overwrite the jobs descriptions even if no description has been defined explicitly. When this option is set to True, that behavior changes and it will only overwrite the description if you specified it in the yaml. False by default.
- include_path
- (Optional) Can be set to a ':' delimited list of paths, which jenkins job builder will search for any files specified by the custom application yaml tags 'include', 'include-raw' and 'include-raw-escaped'.
- recursive
- (Optional) If set to True, jenkins job builder will search for job definition files recursively
jenkins section¶
- user
- This should be the name of a user previously defined in Jenkins. Appropriate user permissions must be set under the Jenkins security matrix: under the Global group of permissions, check Read, then under the Job group of permissions, check Create, Delete, Configure and finally Read.
- password
- The API token for the user specified. You can get this through the Jenkins management interface under People -> username -> Configure and then click the Show API Token button.
- url
- The base URL for your Jenkins installation.
Running¶
After it's installed and configured, you can invoke Jenkins Job Builder by running jenkins-jobs. You won't be able to do anything useful just yet without a configuration which is discussed in the next section.Usage¶
usage: jenkins-jobs.py [-h] [--conf CONF] [-l LOG_LEVEL] [--ignore-cache] [--flush-cache] {update,test,delete,delete-all} ... positional arguments: {update,test,delete,delete-all} update, test or delete job delete-all delete *ALL* jobs from Jenkins server, including those not managed by Jenkins Job Builder. optional arguments: -h, --help show this help message and exit --conf CONF configuration file -l LOG_LEVEL, --log_level LOG_LEVEL log level (default: info) --ignore-cache ignore the cache and update the jobs anyhow (that will only flush the specified jobs cache) --flush-cache flush all the cache entries before updating
Test Mode¶
Once you have a configuration defined, you can run the job builder in test mode. If you want to run a simple test with just a single YAML job definition file and see the XML output on stdout:jenkins-jobs test /path/to/foo.yaml
You can also pass JJB a directory containing multiple job definition files:
jenkins-jobs test /path/to/defs -o /path/to/output
which will write XML files to the output directory for all of the jobs defined in the defs directory.
Updating Jenkins¶
When you're satisfied with the generated XML from the test, you can run:jenkins-jobs update /path/to/defs
which will upload the job definitions to Jenkins if needed. Jenkins Job Builder maintains, for each host, a cache [1] of previously configured jobs, so that you can run that command as often as you like, and it will only update the jobs configurations in Jenkins if the defined definitions has changed since the last time it was run. Note: if you modify a job directly in Jenkins, jenkins-jobs will not know about it and will not update it. To update a specific list of jobs, simply pass them as additional arguments after the job definition path. To update Foo1 and Foo2 run:
jenkins-jobs update /path/to/defs Foo1 Foo2
FOOTNOTES¶
- [1]
- The cache default location is at ~/.cache/jenkins_jobs, which can be overridden by setting the XDG_CACHE_HOME environment variable.
JOB DEFINITIONS¶
The job definitions for Jenkins Job Builder are kept in any number of YAML files, in whatever way you would like to organize them. When you invoke jenkins-jobs you may specify either the path of a single YAML file, or a directory. If you choose a directory, all of the .yaml (or .yml) files in that directory will be read, and all the jobs they define will be created or updated.Definitions¶
Jenkins Job Builder understands a few basic object types which are described in the next sections.Job¶
The most straightforward way to create a job is simply to define a Job in YAML. It looks like this:- job: name: job-name
That's not very useful, so you'll want to add some actions such as builders, and perhaps publishers. Those are described later. There are a few basic optional fields for a Job definition:
- job: name: job-name project-type: freestyle defaults: global disabled: false display-name: 'Fancy job name' concurrent: true workspace: /srv/build-area/job-name child-workspace: /srv/build-area/job-name quiet-period: 5 block-downstream: false block-upstream: false retry-count: 3
- Job Parameters
- •
- project-type: Defaults to "freestyle", but "maven" as well as "multijob" or "flow" can also be specified.
- •
- defaults: Specifies a set of defaults to use for this job, defaults to ''global''. If you have values that are common to all of your jobs, create a global defaults object to hold them, and no further configuration of individual jobs is necessary. If some jobs should not use the global defaults, use this field to specify a different set of defaults.
- •
- disabled: Boolean value to set whether or not this job should be disabled in Jenkins. Defaults to false (job will be enabled).
- •
- display-name: Optional name shown for the project throughout the Jenkins web GUI in place of the actual job name. The jenkins_jobs tool cannot fully remove this trait once it is set, so use caution when setting it. Setting it to the same string as the job's name is an effective un-set workaround. Alternately, the field can be cleared manually using the Jenkins web interface.
- •
- concurrent: Boolean value to set whether or not Jenkins can run this job concurrently. Defaults to false.
- •
- workspace: Path for a custom workspace. Defaults to Jenkins default configuration.
- •
- child-workspace: Path for a child custom workspace. Defaults to Jenkins default configuration.
- •
- quiet-period: Number of seconds to wait between consecutive runs of this job. Defaults to 0.
- •
- block-downstream: Boolean value to set whether or not this job must block while downstream jobs are running. Downstream jobs are determined transitively. Defaults to false.
- •
- block-upstream: Boolean value to set whether or not this job must block while upstream jobs are running. Upstream jobs are determined transitively. Defaults to false.
- •
- auth-token: Specifies an authentication token that allows new builds to be triggered by accessing a special predefined URL. Only those who know the token will be able to trigger builds remotely.
- •
- retry-count: If a build fails to checkout from the repository, Jenkins will retry the specified number of times before giving up.
Job Template¶
If you need several jobs defined that are nearly identical, except perhaps in their names, SCP targets, etc., then you may use a Job Template to specify the particulars of the job, and then use a Project to realize the job with appropriate variable substitution. Any variables not specified at the project level will be inherited from the Defaults. A Job Template has the same syntax as a Job, but you may add variables anywhere in the definition. Variables are indicated by enclosing them in braces, e.g., {name} will substitute the variable name. When using a variable in a string field, it is good practice to wrap the entire string in quotes, even if the rules of YAML syntax don't require it because the value of the variable may require quotes after substitution. In the rare situation that you must encode braces within literals inside a template (for example a shell function definition in a builder), doubling the braces will prevent them from being interpreted as a template variable. You must include a variable in the name field of a Job Template (otherwise, every instance would have the same name). For example:- job-template: name: '{name}-unit-tests'
Will not cause any job to be created in Jenkins, however, it will define a template that you can use to create jobs with a Project definition. It's name will depend on what is supplied to the Project.
Project¶
The purpose of a project is to collect related jobs together, and provide values for the variables in a Job Template. It looks like this:- project: name: project-name jobs: - '{name}-unit-tests'
Any number of arbitrarily named additional fields may be specified, and they will be available for variable substitution in the job template. Any job templates listed under jobs: will be realized with those values. The example above would create the job called 'project-name-unit-tests' in Jenkins. The jobs: list can also allow for specifying job-specific substitutions as follows:
- project: name: project-name jobs: - '{name}-unit-tests': mail-to: developer@nowhere.net - '{name}-perf-tests': mail-to: projmanager@nowhere.net
If a variable is a list, the job template will be realized with the variable set to each value in the list. Multiple lists will lead to the template being realized with the cartesian product of those values. Example:
- project: name: project-name pyver: - 26 - 27 jobs: - '{name}-{pyver}'
If there are templates being realized that differ only in the variable used for its name (thus not a use case for job-specific substitutions), additional variables can be specified for project variables. Example:
- job-template: name: '{name}-{pyver}' builders: - shell: 'git co {branch_name}' - project: name: project-name pyver: - 26: branch_name: old_branch - 27: branch_name: new_branch jobs: - '{name}-{pyver}'
Job Group¶
If you have several Job Templates that should all be realized together, you can define a Job Group to collect them. Simply use the Job Group where you would normally use a Job Template and all of the Job Templates in the Job Group will be realized. For example:- job-template: name: '{name}-unit-tests' builders: - shell: unittest publishers: - email: recipients: '{mail-to}' - job-template: name: '{name}-perf-tests' builders: - shell: perftest publishers: - email: recipients: '{mail-to}' - job-group: name: '{name}-tests' jobs: - '{name}-unit-tests': mail-to: developer@nowhere.net - '{name}-perf-tests': mail-to: projmanager@nowhere.net - project: name: project-name jobs: - '{name}-tests'
Would cause the jobs project-name-unit-tests and project-name-perf-tests to be created in Jenkins.
Macro¶
Many of the actions of a Job, such as builders or publishers, can be defined as a Macro, and then that Macro used in the Job description. Builders are described later, but let's introduce a simple one now to illustrate the Macro functionality. This snippet will instruct Jenkins to execute "make test" as part of the job:- job: name: foo-test builders: - shell: 'make test'
If you wanted to define a macro (which won't save much typing in this case, but could still be useful to centralize the definition of a commonly repeated task), the configuration would look like:
- builder: name: make-test builders: - shell: 'make test' - job: name: foo-test builders: - make-test
This allows you to create complex actions (and even sequences of actions) in YAML that look like first-class Jenkins Job Builder actions. Not every attribute supports Macros, check the documentation for the action before you try to use a Macro for it. Macros can take parameters, letting you define a generic macro and more specific ones without having to duplicate code:
# The 'add' macro takes a 'number' parameter and will creates a # job which prints 'Adding ' followed by the 'number' parameter: - builder: name: add builders: - shell: "echo Adding {number}" # A specialized macro 'addtwo' reusing the 'add' macro but with # a 'number' parameter hardcoded to 'two': - builder: name: addtwo builders: - add: number: "two" # Glue to have Jenkins Job Builder to expand this YAML example: - job: name: "testingjob" builders: # The specialized macro: - addtwo # Generic macro call with a parameter - add: number: "ZERO" # Generic macro called without a parameter. Never do this! # See below for the resulting wrong output :( - add
Then <builders /> section of the generated job show up as:
<builders> <hudson.tasks.Shell> <command>echo Adding two</command> </hudson.tasks.Shell> <hudson.tasks.Shell> <command>echo Adding ZERO</command> </hudson.tasks.Shell> <hudson.tasks.Shell> <command>echo Adding {number}</command> </hudson.tasks.Shell> </builders>
As you can see, the specialized macro addtwo reused the definition from the generic macro add. Whenever you forget a parameter from a macro, it will not be expanded and left as is, which will most probably cause havoc in your Jenkins builds.
Defaults¶
Defaults collect job attributes (including actions) and will supply those values when the job is created, unless superseded by a value in the 'Job'_ definition. If a set of Defaults is specified with the name global, that will be used by all Job (and Job Template) definitions unless they specify a different Default object with the defaults attribute. For example:- defaults: name: global description: 'Do not edit this job through the web!'
Will set the job description for every job created. You can define variables that will be realized in a Job Template.
- defaults: name: global arch: 'i386' - project: name: project-name jobs: - 'build-{arch}' - 'build-{arch}': arch: 'amd64' - job-template: name: 'build-{arch}' builders: - shell: "echo Build arch {arch}."
Would create jobs build-i386 and build-amd64.
Advanced¶
If you want to use lists or dicts variables you can use {obj:key}. For example:- project: name: test_custom_distri distributions: !!python/tuple [precise, jessie] architectures: !!python/tuple &architectures - amd64 - i386 axis_a: type: user-defined name: architectures values: *architectures jobs: - '{name}-source' - job-template: name: '{name}-source' project-type: matrix axes: - axis: type: user-defined name: distribution values: '{obj:distributions}' - axis: '{obj:axis_a}'
Custom Yaml Tags¶
Custom application specific yamls tags are supported to provide enhancements when reading yaml configuration. These allow inclusion of arbitrary files as a method of having blocks of data managed separately to the yaml job configurations. A specific usage of this is inlining scripts contained in separate files, although such tags may also be used to simplify usage of macros or job templates. The tag !include will treat the following string as file which should be parsed as yaml configuration data. Example:- job: name: test-job-1 builders: !include include001.yaml.inc
contents of include001.yaml.inc:
- timeout-wrapper - pre-scm-shell-ant - copy-files
The tag !include-raw will treat the following file as a data blob, which should be read into the calling yaml construct without any further parsing. Any data in a file included through this tag, will be treated as string data. Example:
- job: name: test-job-include-raw-1 builders: - shell: !include-raw include-raw001-hello-world.sh - shell: !include-raw include-raw001-vars.sh
contents of include-raw001-hello-world.sh:
#!/bin/bash # # Sample script showing how the yaml include-raw tag can be used # to inline scripts that are maintained outside of the jenkins # job yaml configuration. echo "hello world" exit 0
contents of include-raw001-vars.sh:
#!/bin/bash # # sample script to check that brackets aren't escaped # when using the include-raw application yaml tag VAR1="hello" VAR2="world" VAR3="${VAR1} ${VAR2}" [[ -n "${VAR3}" ]] && { # this next section is executed as one echo "${VAR3}" exit 0 }
The tag !include-raw-escape treats the given file as a data blob, which should be escaped before being read in as string data. This allows job-templates to use this tag to include scripts from files without needing to escape braces in the original file. Example:
- template-job: name: test-job-include-raw-{num} builders: - shell: !include-raw-escape include-raw001-hello-world.sh - shell: !include-raw-escape include-raw001-vars.sh - project: name: test-job-template-1 num: 1 jobs: - 'test-job-include-raw-{num}'
contents of include-raw001-hello-world.sh:
#!/bin/bash # # Sample script showing how the yaml include-raw tag can be used # to inline scripts that are maintained outside of the jenkins # job yaml configuration. echo "hello world" exit 0
contents of include-raw001-vars.sh:
#!/bin/bash # # sample script to check that brackets aren't escaped # when using the include-raw application yaml tag VAR1="hello" VAR2="world" VAR3="${VAR1} ${VAR2}" [[ -n "${VAR3}" ]] && { # this next section is executed as one echo "${VAR3}" exit 0 }
Modules¶
The bulk of the job definitions come from the following modules.Flow Project¶
The flow Project module handles creating Jenkins flow projects. You may specify flow in the project-type attribute of the Job definition. Requires the Jenkins Build Flow Plugin. Example:job: name: test_job project-type: flow dsl: | build("job1") parallel ( { build("job2a") }, { build("job2b") } )
Freestyle Project¶
The Freestyle Project module handles creating freestyle Jenkins projects (i.e., those that do not use Maven). You may specify freestyle in the project-type attribute to the Job definition if you wish, though it is the default, so you may omit project-type altogether if you are creating a freestyle project. Example:job: name: test_job project-type: freestyle
Maven Project¶
The Maven Project module handles creating Maven Jenkins projects. To create a Maven project, specify maven in the project-type attribute to the Job definition. It also requires a maven section in the Job definition.- Job Parameters
- •
- root-module:
- •
- group-id (str): GroupId.
- •
- artifact-id (str): ArtifactId.
- •
- root-pom (str): The path to the pom.xml file. (default 'pom.xml')
- •
- goals (str): Goals to execute. (required)
- •
- maven-opts (str): Java options to pass to maven (aka MAVEN_OPTS)
- •
- maven-name (str): Installation of maven which should be used. Not setting maven-name appears to use the first maven install defined in the global jenkins config.
- •
- private-repository ('str'): Whether to use a private maven repository Possible values are default, local-to-workspace and local-to-executor.
- •
- ignore-upstream-changes (bool): Do not start a build whenever a SNAPSHOT dependency is built or not. (default true)
- •
- automatic-archiving (bool): Activate automatic artifact archiving (default true).
- •
- settings (str): Path to custom maven settings file (optional)
- •
- global-settings (str): Path to custom maven global settings file (optional)
Example:
project-type: maven maven: root-pom: pom.xml goals: deploy root-module: group-id: gabba.gabba artifact-id: hey settings: test global-settings: test
Matrix Project¶
The matrix project module handles creating Jenkins matrix projects. To create a matrix project specify matrix in the project-type attribute to the Job definition. Currently it only supports three axes which share the same internal YAML structure:- •
- label expressions (label-expression)
- •
- user-defined values (user-defined)
- •
- slave name or label (slave)
The module supports also dynamic axis:
- •
- dynamic (dynamic)
Requires the Jenkins dynamic axis Plugin.
- Job Parameters
- •
- execution-strategy (optional):
- •
- combination-filter (str): axes selection filter
- •
- sequential (bool): run builds sequentially (default false)
- •
- touchstone (optional):
- •
- expr (str) -- selection filter for the touchstone build
- •
- result (str) -- required result of the job: stable (default) or unstable
- •
- axes (list):
- •
- axis:
- •
- type (str) -- axis type, must be either 'label-expression', 'user-defined' or 'slave'.
- •
- name (str) -- name of the axis
- •
- values (list) -- values of the axis
Example:
- job: name: matrix-test project-type: matrix execution-strategy: combination-filter: | !(os=="fedora11" && arch=="amd64") sequential: true touchstone: expr: 'os == "fedora11"' result: unstable axes: - axis: type: label-expression name: os values: - ubuntu12.04 - fedora11 - axis: type: label-expression name: arch values: - amd64 - i386 - axis: type: slave name: nodes values: - node1 - node2 - axis: type: dynamic name: config values: - config_list builders: - shell: make && make check
Example using user-defined axis:
- job: name: matrix-user-defined project-type: matrix axes: - axis: type: user-defined name: database values: - mysql - postgresql - sqlite builders: - shell: make "$database"
Builders¶
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.- Component: builders
- Macro
- builder
- Entry Point
- jenkins_jobs.builders
Example:
job: name: test_job builders: - shell: "make test"
- ant
- 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
- •
- targets (str) -- the space separated list of ANT targets.
- •
- buildfile (str) -- the path to the ANT build file.
- •
- properties (list) -- Passed to ant script using -Dkey=value (optional)
- •
- ant-name (str) -- the name of the ant installation, (default 'default') (optional)
- •
- java-opts (str) -- java options for ant, can have multiples, must be in quotes (optional)
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"
- artifact-resolver
- Allows one to resolve artifacts from a maven repository like nexus (without having maven installed) Requires the Jenkins Repository Connector Plugin
- Parameters
- •
- fail-on-error (bool) -- Whether to fail the build on error (default false)
- •
- repository-logging (bool) -- Enable repository logging (default false)
- •
- target-directory (str) -- Where to resolve artifacts to
- •
- artifacts (list) -- list of artifacts to resolve
- Artifact
- •
- group-id (str) -- Group ID of the artifact
- •
- artifact-id (str) -- Artifact ID of the artifact
- •
- version (str) -- Version of the artifact
- •
- classifier (str) -- Classifier of the artifact (default '')
- •
- extension (str) -- Extension of the artifact (default 'jar')
- •
- target-file-name (str) -- What to name the artifact (default '')
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"
- batch
- Execute a batch command.
- Parameter
- the batch command to execute
Example:
builders: - batch: "foo/foo.bat"
- builders-from
- 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-assembly-version
- Change the assembly version. Requires the Jenkins Change Assembly Version.
- Parameters
- •
- version (str) -- Set the new version number for replace (default 1.0.0)
- •
- assemblyFile (str) -- The file name to search (default AssemblyInfo.cs)
Example:
builders: - change-assembly-version: version: "1.2.3" assembly-file: "AFile"
- conditional-step
- 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 (str) -- Condition kind that must be verified before the steps are executed. Valid values and their additional attributes are described in the conditions table.
- •
- on-evaluation-failure (str) -- What should be the outcome of the build if the evaluation of the condition fails. Possible values are fail, mark-unstable, run-and-mark-unstable, run and dont-run. Default is fail.
- •
- steps (list) -- List of steps to run if the condition is verified. Items in the list can be any builder known by Jenkins Job Builder.
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 7.0 3.5 0.0 condition-expression Expression to expand 168u 168u 168u |
current-status | Run the build step if the current build status is within the configured range 7.0 3.5 0.0 condition-worst Accepted values are SUCCESS, UNSTABLE, FAILURE, NOT_BUILD, ABORTED condition-best Accepted values are SUCCESS, UNSTABLE, FAILURE, NOT_BUILD, ABORTED 168u 168u 168u |
shell | Run the step if the shell command succeed 7.0 3.5 0.0 condition-command Shell command to execute 168u 168u 168u |
windows-shell | Similar to shell, except that commands will be executed by cmd, under Windows 7.0 3.5 0.0 condition-command Command to execute 168u 168u 168u |
file-exists | Run the step if a file exists 7.0 3.5 0.0 condition-filename Check existence of this file condition-basedir If condition-filename is relative, it will be considered relative to either workspace, artifact-directory, or jenkins-home. Default is workspace. 168u 168u 168u |
builders: - conditional-step: condition-kind: current-status condition-worst: SUCCESS condition-best: FAILURE steps: - shell: "sl"
- copyartifact
- Copy artifact from another project. Requires the Jenkins Copy Artifact plugin.
- Parameters
- •
- project (str) -- Project to copy from
- •
- filter (str) -- what files to copy
- •
- target (str) -- Target base directory for copy, blank means use workspace
- •
- flatten (bool) -- Flatten directories (default: false)
- •
- optional (bool) -- If the artifact is missing (for any reason) and optional is true, the build won't fail because of this builder (default: false)
- •
- which-build (str) -- which build to get artifacts from (optional, default last-successful)
- •
- build-number (str) -- specifies the build number to get when when specific-build is specified as which-build
- •
- permalink (str) -- specifies the permalink to get when permalink is specified as which-build
- •
- stable (bool) -- specifies to get only last stable build when last-successful is specified as which-build
- •
- fallback-to-last-successful (bool) -- specifies to fallback to last successful build when upstream-build is specified as which-build
- •
- param (string) -- specifies to use a build parameter to get the build when build-param is specified as which-build
- •
- parameter-filters (string) -- Filter matching jobs based on these parameters (optional)
- Which-build values
- •
- last-successful
- •
- specific-build
- •
- last-saved
- •
- upstream-build
- •
- permalink
- •
- workspace-latest
- •
- build-param
- Permalink values
- •
- last
- •
- last-stable
- •
- last-successful
- •
- last-failed
- •
- last-unstable
- •
- last-unsuccessful
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
- critical-block-end
- 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
- critical-block-start
- 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
- gradle
- Execute gradle tasks. Requires the Jenkins Gradle Plugin.
- Parameters
- •
- tasks (str) -- List of tasks to execute
- •
- gradle-name (str) -- Use a custom gradle name (optional)
- •
- wrapper (bool) -- use gradle wrapper (default false)
- •
- executable (bool) -- make gradlew executable (default false)
- •
- switches (list) -- Switches for gradle, can have multiples
- •
- use-root-dir (bool) -- Whether to run the gradle script from the top level directory or from a different location (default false)
- •
- root-build-script-dir (str) -- If your workspace has the top-level build.gradle in somewhere other than the module root directory, specify the path (relative to the module root) here, such as ${workspace}/parent/ instead of just ${workspace}.
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
- grails
- Execute a grails build step. Requires the Jenkins Grails Plugin.
- Parameters
- •
- use-wrapper (bool) -- Use a grails wrapper (default false)
- •
- name (str) -- Select a grails installation to use (optional)
- •
- force-upgrade (bool) -- Run 'grails upgrade --non-interactive' first (default false)
- •
- non-interactive (bool) -- append --non-interactive to all build targets (default false)
- •
- targets (str) -- Specify target(s) to run separated by spaces
- •
- server-port (str) -- Specify a value for the server.port system property (optional)
- •
- work-dir (str) -- Specify a value for the grails.work.dir system property (optional)
- •
- project-dir (str) -- Specify a value for the grails.project.work.dir system property (optional)
- •
- base-dir (str) -- Specify a path to the root of the Grails project (optional)
- •
- properties (str) -- Additional system properties to set (optional)
- •
- plain-output (bool) -- append --plain-output to all build targets (default false)
- •
- stack-trace (bool) -- append --stack-trace to all build targets (default false)
- •
- verbose (bool) -- append --verbose to all build targets (default false)
- •
- refresh-dependencies (bool) -- append --refresh-dependencies to all build targets (default false)
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"
- groovy
- Execute a groovy script or command. Requires the Jenkins Groovy Plugin
- Parameters
- •
- file (str) -- Groovy file to run. (Alternative: you can chose a command instead)
- •
- command (str) -- Groovy command to run. (Alternative: you can chose a script file instead)
- •
- version (str) -- Groovy version to use. (default '(Default)')
- •
- parameters (str) -- Parameters for the Groovy executable. (optional)
- •
- script-parameters (str) -- These parameters will be passed to the script. (optional)
- •
- properties (str) -- Instead of passing properties using the -D parameter you can define them here. (optional)
- •
- java-opts (str) -- Direct access to JAVA_OPTS. Properties allows only -D properties, while sometimes also other properties like -XX need to be setup. It can be done here. This line is appended at the end of JAVA_OPTS string. (optional)
- •
- class-path (str) -- Specify script classpath here. Each line is one class path item. (optional)
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
- Inject an environment for the job. Requires the Jenkins EnvInject Plugin.
- Parameters
- •
- properties-file (str) -- the name of the property file (optional)
- •
- properties-content (str) -- the properties content (optional)
Example:
builders: - inject: properties-file: example.prop properties-content: EXAMPLE=foo-bar
- managed-script
- This step allows to reference and execute a centrally managed script within your build. Requires the Jenkins Managed Script Plugin.
- Parameters
- •
- script-id (str) -- Id of script to execute (Required)
- •
- type (str) -- Type of managed file (default: script)
- type values
- •
- batch: Execute managed windows batch
- •
- script: Execute managed script
- •
- args (list) -- Arguments to be passed to referenced script
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
- maven-target
- Execute top-level Maven targets
- Parameters
- •
- goals (str) -- Goals to execute
- •
- properties (str) -- Properties for maven, can have multiples
- •
- pom (str) -- Location of pom.xml (default 'pom.xml')
- •
- private-repository (bool) -- Use private maven repository for this job (default false)
- •
- maven-version (str) -- Installation of maven which should be used (optional)
- •
- java-opts (str) -- java options for maven, can have multiples, must be in quotes (optional)
- •
- settings (str) -- Path to use as user settings.xml (optional)
- •
- global-settings (str) -- Path to use as global settings.xml (optional)
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
- msbuild
- Build .NET project using msbuild. Requires the Jenkins MSBuild Plugin.
- Parameters
- •
- msbuild-version (str) -- which msbuild configured in Jenkins to use (optional)
- •
- solution-file (str) -- location of the solution file to build
- •
- extra-parameters (str) -- extra parameters to pass to msbuild (optional)
- •
- pass-build-variables (bool) -- should build variables be passed to msbuild (default true)
- •
- continue-on-build-failure (bool) -- should the build continue if msbuild returns an error (default false)
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
- multijob
- Define a multijob phase. Requires the Jenkins Multijob Plugin. This builder may only be used in jenkins_jobs.modules.project_multijob.MultiJob projects.
- Parameters
- •
- name (str) -- MultiJob phase name
- •
- condition (str) -- when to trigger the other job (default 'SUCCESSFUL')
- •
- projects (list) -- list of projects to include in the MultiJob phase
- Project
- •
- name (str) -- Project name
- •
- current-parameters (bool) -- Pass current build parameters to the other job (default false)
- •
- node-label-name (str) -- Define a list of nodes on which the job should be allowed to be executed on. Requires NodeLabel Parameter Plugin (optional)
- •
- node-label (str) -- Define a label of 'Restrict where this project can be run' on the fly. Requires NodeLabel Parameter Plugin (optional)
- •
- git-revision (bool) -- Pass current git-revision to the other job (default false)
- •
- property-file (str) -- Pass properties from file to the other job (optional)
- •
- predefined-parameters (str) -- Pass predefined parameters to the other job (optional)
- •
- kill-phase-on (str) -- Stop the phase execution on specific job status. Can be 'FAILURE', 'UNSTABLE', 'NEVER'. (optional)
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
- powershell
- Execute a powershell command. Requires the Powershell Plugin.
- Parameter
- the powershell command to execute
Example:
builders: - powershell: "foo/foo.ps1"
- python
- Execute a python command. Requires the Jenkins Python plugin.
- Parameters
- parameter (str) -- the python command to execute
Example:
builders: - python: 'import foobar'
- sbt
- Execute a sbt build step. Requires the Jenkins Sbt Plugin.
- Parameters
- •
- name (str) -- Select a sbt installation to use. If no name is provided, the first in the list of defined SBT builders will be used. (default to first in list)
- •
- jvm-flags (str) -- Parameters to pass to the JVM (default '')
- •
- actions (str) -- Select the sbt tasks to execute (default '')
- •
- sbt-flags (str) -- Add flags to SBT launcher (default '-Dsbt.log.noformat=true')
- •
- subdir-path (str) -- Path relative to workspace to run sbt in (default '')
Example:
builders: - sbt: name: "default" actions: "clean package" jvm-flags: "-Xmx8G"
- shell
- Execute a shell command.
- Parameters
- parameter (str) -- the shell command to execute
Example:
builders: - shell: "make test"
- shining-panda
- Execute a command inside various python environments. Requires the Jenkins ShiningPanda plugin.
- Parameters
- build-environment (str) -- Building environment to set up (Required).
- build-environment values
- •
- python: Use a python installation configured in Jenkins.
- •
- custom: Use a manually installed python.
- •
- virtualenv: Create a virtualenv
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
- •
- 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)
- •
- name (str) -- Name of this virtualenv. Two virtualenv builders with the same name will use the same virtualenv installation (optional)
- •
- clear (bool) -- If true, delete and recreate virtualenv on each build. (default: false)
- •
- use-distribute (bool) -- if true use distribute, if false use setuptools. (default: true)
- •
- system-site-packages (bool) -- if true, give access to the global site-packages directory to the virtualenv. (default: false)
Common to all environments:
- Parameters
- •
- nature (str) -- Nature of the command field. (default: shell)
- nature values
- •
- shell: execute the Command contents with default shell
- •
- xshell: like shell but performs platform conversion first
- •
- python: execute the Command contents with the Python executable
- •
- command (str) -- The command to execute
- •
- ignore-exit-code (bool) -- mark the build as failure if any of the commands exits with a non-zero exit code. (default: false)
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
- ssh
- Send files or execute commands over SSH. Requires the Jenkins Publish over SSH Plugin.
- Parameters
- •
- site (str) -- name of the ssh site
- •
- target (str) -- destination directory
- •
- target-is-date-format (bool) -- whether target is a date format. If true, raw text should be quoted (defaults to False)
- •
- clean-remote (bool) -- should the remote directory be deleted before transferring files (defaults to False)
- •
- source (str) -- source path specifier
- •
- command (str) -- a command to execute on the remote server (optional)
- •
- timeout (int) -- timeout in milliseconds for the Exec command (optional)
- •
- use-pty (bool) -- run the exec command in pseudo TTY (defaults to False)
- •
- excludes (str) -- excluded file pattern (optional)
- •
- remove-prefix (str) -- prefix to remove from uploaded file paths (optional)
- •
- fail-on-error (bool) -- fail the build if an error occurs (defaults to False).
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
- system-groovy
- Execute a system groovy script or command. Requires the Jenkins Groovy Plugin
- Parameters
- •
- file (str) -- Groovy file to run. (Alternative: you can chose a command instead)
- •
- command (str) -- Groovy command to run. (Alternative: you can chose a script file instead)
- •
- bindings (str) -- Define variable bindings (in the properties file format). Specified variables can be addressed from the script. (optional)
- •
- class-path (str) -- Specify script classpath here. Each line is one class path item. (optional)
Examples:
builders: - system-groovy: file: "test.groovy"
builders: - system-groovy: command: "Some command" bindings: "Some bindings" class-path: "Some classpath"
- trigger-builds
- Trigger builds of other jobs. Requires the Jenkins Parameterized Trigger Plugin.
- Parameters
- •
- project (str) -- the Jenkins project to trigger
- •
- predefined-parameters (str) -- key/value pairs to be passed to the job (optional)
- •
- property-file (str) -- Pass properties from file to the other job (optional)
- •
- property-file-fail-on-missing (bool) -- Don't trigger if any files are missing (optional) (default true)
- •
- current-parameters (bool) -- Whether to include the parameters passed to the current build to the triggered job.
- •
- svn-revision (bool) -- Whether to pass the svn revision to the triggered job
- •
- block (bool) -- whether to wait for the triggered jobs to finish or not (default false)
- •
- same-node (bool) -- Use the same node for the triggered builds that was used for this build (optional)
- •
- parameter-factories (list) -- list of parameter factories
- Factory
- •
- factory (str) filebuild -- For every property file, invoke one build
- •
- file-pattern (str) -- File wildcard pattern
- •
- no-files-found-action (str) -- Action to perform when no files found (optional) ['FAIL', 'SKIP', 'NOPARMS'] (default 'SKIP')
- Factory
- •
- factory (str) binaryfile -- For every matching file, invoke one build
- •
- file-pattern (str) -- Artifact ID of the artifact
- •
- no-files-found-action (str) -- Action to perform when no files found (optional) ['FAIL', 'SKIP', 'NOPARMS'] (default 'SKIP')
- Factory
- •
- factory (str) counterbuild -- Invoke i=0...N builds
- •
- from (int) -- Artifact ID of the artifact
- •
- to (int) -- Version of the artifact
- •
- step (int) -- Classifier of the artifact
- •
- parameters (str) -- KEY=value pairs, one per line (default '')
- •
- validation-fail (str) -- Action to perform when stepping validation fails (optional) ['FAIL', 'SKIP', 'NOPARMS'] (default 'FAIL')
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
Hipchat¶
Enable hipchat notification of build execution. Example:- job: name: test_job hipchat: enabled: true room: Testjob Build Notifications start-notify: true
In the jenkins UI specification, the hipchat plugin must be explicitly selected as a publisher. This is not required (or supported) here - use the enabled parameter to enable/disable the publisher action. If you set enabled: false, no hipchat parameters are written to XML.
Metadata¶
The Metadata plugin module enables the ability to add metadata to the projects that can be exposed to job environment. Requires the Jenkins Metadata Plugin.- Component: metadata
- Macro
- metadata
- Entry Point
- jenkins_jobs.metadata
Example:
metadata: - string: name: FOO value: bar expose-to-env: true
- date
- A date metadata
- Parameters
- •
- name (str) -- the name of the metadata
- •
- time (str) -- time value in millisec since 1970-01-01 00:00:00 UTC
- •
- timezone (str) -- time zone of the metadata
- •
- expose-to-env (bool) -- expose to environment (optional)
Example:
metadata: - date: name: FOO value: 1371708900268 timezone: Australia/Melbourne expose-to-env: true
- number
- A number metadata.
- Parameters
- •
- name (str) -- the name of the metadata
- •
- value (str) -- the value of the metadata
- •
- expose-to-env (bool) -- expose to environment (optional)
Example:
metadata: - number: name: FOO value: 1 expose-to-env: true
- string
- A string metadata.
- Parameters
- •
- name (str) -- the name of the metadata
- •
- value (str) -- the value of the metadata
- •
- expose-to-env (bool) -- expose to environment (optional)
Example:
metadata: - string: name: FOO value: bar expose-to-env: true
Notifications¶
The Notifications module allows you to configure Jenkins to notify other applications about various build phases. It requires the Jenkins notification plugin.- Component: notifications
- Macro
- notification
- Entry Point
- jenkins_jobs.notifications
Example:
job: name: test_job notifications: - http: url: http://example.com/jenkins_endpoint
- http
- Defines an HTTP notification endpoint. Requires the Jenkins Notification Plugin.
- Parameters
- url (str) -- URL of the endpoint
Example:
notifications: - http: url: http://example.com/jenkins_endpoint
Parameters¶
The Parameters module allows you to specify build parameters for a job.- Component: parameters
- Macro
- parameter
- Entry Point
- jenkins_jobs.parameters
Example:
job: name: test_job parameters: - string: name: FOO default: bar description: "A parameter named FOO, defaults to 'bar'."
- bool
- A boolean parameter.
- Parameters
- •
- name (str) -- the name of the parameter
- •
- default (str) -- the default value of the parameter (optional)
- •
- description (str) -- a description of the parameter (optional)
Example:
parameters: - bool: name: FOO default: false description: "A parameter named FOO, defaults to 'false'."
- choice
- A single selection parameter.
- Parameters
- •
- name (str) -- the name of the parameter
- •
- choices (list) -- the available choices
- •
- description (str) -- a description of the parameter (optional)
Example:
parameters: - choice: name: project choices: - nova - glance description: "On which project to run?"
- dynamic-choice
- Dynamic Choice Parameter Requires the Jenkins Jenkins Dynamic Parameter Plug-in.
- Parameters
- •
- name (str) -- the name of the parameter
- •
- description (str) -- a description of the parameter (optional)
- •
- script (str) -- Groovy expression which generates the potential choices.
- •
- remote (bool) -- the script will be executed on the slave where the build is started (default false)
- •
- classpath (str) -- class path for script (optional)
- •
- read-only (bool) -- user can't modify parameter once populated (default false)
Example:
parameters: - dynamic-choice: name: OPTIONS description: "Available options" script: "['optionA', 'optionB']" remote: false read-only: false
- dynamic-choice-scriptler
- Dynamic Choice Parameter (Scriptler) Requires the Jenkins Jenkins Dynamic Parameter Plug-in.
- Parameters
- •
- name (str) -- the name of the parameter
- •
- description (str) -- a description of the parameter (optional)
- •
- script-id (str) -- Groovy script which generates the default value
- •
- parameters (list) -- parameters to corresponding script
- Parameter
- •
- name (str) Parameter name
- •
- value (str) Parameter value
- •
- remote (bool) -- the script will be executed on the slave where the build is started (default false)
- •
- read-only (bool) -- user can't modify parameter once populated (default false)
Example:
parameters: - dynamic-choice-scriptler: name: OPTIONS description: "Available options" script-id: "scriptid.groovy" parameters: - name: param1 value: value1 - name: param2 value: value2 remote: false read-only: false
- dynamic-string
- Dynamic Parameter Requires the Jenkins Jenkins Dynamic Parameter Plug-in.
- Parameters
- •
- name (str) -- the name of the parameter
- •
- description (str) -- a description of the parameter (optional)
- •
- script (str) -- Groovy expression which generates the potential choices
- •
- remote (bool) -- the script will be executed on the slave where the build is started (default false)
- •
- classpath (str) -- class path for script (optional)
- •
- read-only (bool) -- user can't modify parameter once populated (default false)
Example:
parameters: - dynamic-string: name: FOO description: "A parameter named FOO, defaults to 'bar'." script: "bar" remote: false read-only: false
- dynamic-string-scriptler
- Dynamic Parameter (Scriptler) Requires the Jenkins Jenkins Dynamic Parameter Plug-in.
- Parameters
- •
- name (str) -- the name of the parameter
- •
- description (str) -- a description of the parameter (optional)
- •
- script-id (str) -- Groovy script which generates the default value
- •
- parameters (list) -- parameters to corresponding script
- Parameter
- •
- name (str) Parameter name
- •
- value (str) Parameter value
- •
- remote (bool) -- the script will be executed on the slave where the build is started (default false)
- •
- read-only (bool) -- user can't modify parameter once populated (default false)
Example:
parameters: - dynamic-string-scriptler: name: FOO description: "A parameter named FOO, defaults to 'bar'." script-id: "scriptid.groovy" parameters: - name: param1 value: value1 - name: param2 value: value2 remote: false read-only: false
- file
- A file parameter.
- Parameters
- •
- name (str) -- the target location for the file upload
- •
- description (str) -- a description of the parameter (optional)
Example:
parameters: - file: name: test.txt description: "Upload test.txt."
- label
- A node label parameter.
- Parameters
- •
- name (str) -- the name of the parameter
- •
- default (str) -- the default value of the parameter (optional)
- •
- description (str) -- a description of the parameter (optional)
Example:
parameters: - label: name: node default: precise description: "The node on which to run the job"
- password
- A password parameter.
- Parameters
- •
- name (str) -- the name of the parameter
- •
- default (str) -- the default value of the parameter (optional)
- •
- description (str) -- a description of the parameter (optional)
Example:
parameters: - password: name: FOO default: 1HSC0Ts6E161FysGf+e1xasgsHkgleLh09JUTYnipPvw= description: "A parameter named FOO."
- string
- A string parameter.
- Parameters
- •
- name (str) -- the name of the parameter
- •
- default (str) -- the default value of the parameter (optional)
- •
- description (str) -- a description of the parameter (optional)
Example:
parameters: - string: name: FOO default: bar description: "A parameter named FOO, defaults to 'bar'."
- svn-tags
- A svn tag parameter Requires the Jenkins Parameterized Trigger Plugin.
- Parameters
- •
- name (str) -- the name of the parameter
- •
- default (str) -- the default value of the parameter (optional)
- •
- description (str) -- a description of the parameter (optional)
- •
- url (str) -- the url to list tags from
- •
- filter (str) -- the regular expression to filter tags
Example:
parameters: - svn-tags: name: BRANCH_NAME default: release description: A parameter named BRANCH_NAME default is release url: http://svn.example.com/repo filter: [A-za-z0-9]*
- text
- A text parameter.
- Parameters
- •
- name (str) -- the name of the parameter
- •
- default (str) -- the default value of the parameter (optional)
- •
- description (str) -- a description of the parameter (optional)
Example:
parameters: - text: name: FOO default: bar description: "A parameter named FOO, defaults to 'bar'."
- validating-string
- A validating string parameter Requires the Jenkins Validating String Plugin.
- Parameters
- •
- name (str) -- the name of the parameter
- •
- default (str) -- the default value of the parameter (optional)
- •
- description (str) -- a description of the parameter (optional)
- •
- regex (str) -- a regular expression to validate the string
- •
- msg (str) -- a message to display upon failed validation
Example:
parameters: - validating-string: name: FOO default: bar description: "A parameter named FOO, defaults to 'bar'." regex: [A-Za-z]* msg: Your entered value failed validation
Properties¶
The Properties module supplies a wide range of options that are implemented as Jenkins job properties.- Component: properties
- Macro
- property
- Entry Point
- jenkins_jobs.properties
Example:
job: name: test_job properties: - github: url: https://github.com/openstack-infra/jenkins-job-builder/
- authenticated-build
- Specifies an authorization matrix where only authenticated users may trigger a build. DEPRECATED Example:
properties: - authenticated-build
- authorization
- Specifies an authorization matrix
- The available rights are:
- job-delete job-configure job-read job-extended-read job-discover job-build job-workspace job-cancel run-delete run-update scm-tag
Example:
properties: - authorization: admin: - job-delete - job-configure - job-read - job-discover - job-build - job-workspace - job-cancel - run-delete - run-update - scm-tag anonymous: - job-discover - job-read - job-extended-read
- batch-tasks
- Batch tasks can be tasks for events like releases, integration, archiving, etc. In this way, anyone in the project team can execute them in a way that leaves a record. A batch task consists of a shell script and a name. When you execute a build, the shell script gets run on the workspace, just like a build. Batch tasks and builds "lock" the workspace, so when one of those activities is in progress, all the others will block in the queue. Requires the Jenkins Batch Task Plugin.
- Parameters
- batch-tasks (list) -- Batch tasks.
- Task
- •
- name (str) Task name.
- •
- script (str) Task script.
Example:
properties: - batch-tasks: - name: release script: mvn -B release:prepare release:perform - name: say hello script: echo "Hello world"
- build-blocker
- This plugin keeps the actual job in the queue if at least one name of currently running jobs is matching with one of the given regular expressions. Requires the Jenkins Build Blocker Plugin.
- Parameters
- •
- use-build-blocker (bool) -- Enable or disable build blocker (optional) (default true)
- •
- blocking-jobs (list) -- One regular expression per line to select blocking jobs by their names. (required)
Example:
properties: - build-blocker: use-build-blocker: true blocking-jobs: - ".*-deploy" - "^maintenance.*"
- builds-chain-fingerprinter
- Builds chain fingerprinter. Requires the Jenkins Builds chain fingerprinter Plugin.
- Parameters
- •
- per-builds-chain (bool) -- enable builds hierarchy fingerprinting (default False)
- •
- per-job-chain (bool) -- enable jobs hierarchy fingerprinting (default False)
Example:
properties: - builds-chain-fingerprinter: per-builds-chain: true per-job-chain: true
- copyartifact
- Specify a list of projects that have access to copy the artifacts of this project. Requires the Jenkins Copy Artifact plugin.
- Parameters
- projects (string) -- comma separated list of projects that can copy artifacts of this project. Wild card character '*' is available.
Example:
properties: - copyartifact: projects: foo*
- delivery-pipeline
- Requires the Jenkins Delivery Pipeline Plugin.
- Parameters
- •
- stage (str) -- Name of the stage for this job (default: '')
- •
- task (str) -- Name of the task for this job (default: '')
Example:
properties: - delivery-pipeline: stage: Stage task: Task
- extended-choice
- Creates an extended choice property where values can be read from a file Requires the Jenkins Extended Choice Parameter Plugin.
- Parameters
- •
- name (string) -- name of the property
- •
- description (string) -- description of the property (optional, default '')
- •
- property-file (string) -- location of property file to read from (optional, default '')
- •
- property-key (string) -- key for the property-file (optional, default '')
- •
- quote-value (bool) -- whether to put quotes around the property when passing to Jenkins (optional, default false)
- •
- visible-items (string) -- number of items to show in the list (optional, default 5)
- •
- type (string) -- type of select (optional, default single-select)
- •
- value (string) -- comma separated list of values for the single select or multi-select box (optional, default '')
- •
- default-value (string) -- used to set the initial selection of the single-select or multi-select box (optional, default '')
- •
- default-property-file (string) -- location of property file when default value needs to come from a property file (optional, default '')
- •
- default-property-key (string) -- key for the default property file (optional, default '')
Example:
properties: - extended-choice: name: FOO description: A foo property property-file: /home/foo/property.prop property-key: key quote-value: true visible-items: 10 type: multi-select value: foo,bar,select default-value: foo default-property-file: /home/property.prop default-property-key: fookey
- github
- Sets the GitHub URL for the project.
- Parameters
- url (str) -- the GitHub URL
Example:
properties: - github: url: https://github.com/openstack-infra/jenkins-job-builder/
- heavy-job
- This plugin allows you to define "weight" on each job, and making each job consume that many executors Requires the Jenkins Heavy Job Plugin.
- Parameters
- weight (int) -- Specify the total number of executors that this job should occupy (default 1)
Example:
properties: - heavy-job: weight: 2
- inject
- Allows you to inject evironment variables into the build. Requires the Jenkins Env Inject Plugin.
- Parameters
- •
- properties-file (str) -- file to read with properties (optional)
- •
- properties-content (str) -- key=value properties (optional)
- •
- script-file (str) -- file with script to run (optional)
- •
- script-content (str) -- script to run (optional)
- •
- groovy-content (str) -- groovy script to run (optional)
- •
- load-from-master (bool) -- load files from master (default false)
- •
- enabled (bool) -- injection enabled (default true)
- •
- keep-system-variables (bool) -- keep system variables (default true)
- •
- keep-build-variables (bool) -- keep build variable (default true)
Example:
properties: - inject: properties-content: FOO=bar
- least-load
- Enables the Least Load Plugin. Requires the Jenkins Least Load Plugin.
- Parameters
- disabled (bool) -- whether or not leastload is disabled (default True)
Example:
properties: - least-load: disabled: False
- ownership
- Plugin provides explicit ownership for jobs and slave nodes. Requires the Jenkins Ownership Plugin.
- Parameters
- •
- enabled (bool) -- whether ownership enabled (default : true)
- •
- owner (str) -- the owner of job
- •
- co-owners (list) -- list of job co-owners
Example:
properties: - ownership: owner: abraverm co-owners: - lbednar - edolinin
- priority-sorter
- Allows simple ordering of builds, using a configurable job priority. Requires the Jenkins Priority Sorter Plugin.
- Parameters
- priority (int) -- Priority of the job. Higher value means higher priority, with 100 as the standard priority. (required)
Example:
properties: - priority-sorter: priority: 150
- promoted-build
- Marks a build for promotion. A promotion process with an identical name must be created via the web interface in the job in order for the job promotion to persist. Promotion processes themselves cannot be configured by jenkins-jobs due to the separate storage of plugin configuration files. Requires the Jenkins Promoted Builds Plugin.
- Parameters
- names (list) -- the promoted build names
Example:
properties: - promoted-build: names: - "Release to QA" - "Jane Must Approve"
- slave-utilization
- This plugin allows you to specify the percentage of a slave's capacity a job wants to use. Requires the Jenkins Slave Utilization Plugin.
- Parameters
- •
- slave-percentage (int) -- Specify the percentage of a slave's execution slots that this job should occupy (default: 0)
- •
- single-instance-per-slave (bool) -- Control whether concurrent instances of this job will be permitted to run in parallel on a single slave (default: False)
Example:
properties: - slave-utilization: slave-percentage: 40 single-instance-per-slave: false
- throttle
- Throttles the number of builds for this job. Requires the Jenkins Throttle Concurrent Builds Plugin.
- Parameters
- •
- max-per-node (int) -- max concurrent builds per node (default 0)
- •
- max-total (int) -- max concurrent builds (default 0)
- •
- enabled (bool) -- whether throttling is enabled (default True)
- •
- option (str) -- throttle project or category
- •
- categories (list) -- multiproject throttle categories
Example:
properties: - throttle: max-total: 4 categories: - cat1 - cat2
- zeromq-event
- This is a Jenkins plugin that will publish Jenkins Job run events (start, complete, finish) to a ZMQ PUB socket. Requires the Jenkins ZMQ Event Publisher. Example:
properties: - zeromq-event
Publishers¶
Publishers define actions that the Jenkins job should perform after the build is complete.- Component: publishers
- Macro
- publisher
- Entry Point
- jenkins_jobs.publishers
- aggregate-tests
- Aggregate downstream test results
- Parameters
- include-failed-builds (bool) -- whether to include failed builds
Example:
publishers: - aggregate-tests: include-failed-builds: true
- archive
- Archive build artifacts
- Parameters
- •
- artifacts (str) -- path specifier for artifacts to archive
- •
- excludes (str) -- path specifier for artifacts to exclude
- •
- latest-only (bool) -- only keep the artifacts from the latest successful build
- •
- allow-empty (bool) -- pass the build if no artifacts are found (default false)
Example:
publishers: - archive: artifacts: '*.tar.gz' allow-empty: 'true'
- artifact-deployer
- This plugin makes it possible to copy artifacts to remote locations. Requires the Jenkins ArtifactDeployer Plugin.
- Parameters
- •
- entries (list) -- .INDENT 2.0
- entries
- •
- files (str) - files to deploy
- •
- basedir (str) - the dir from files are deployed
- •
- excludes (str) - the mask to exclude files
- •
- remote (str) - a remote output directory
- •
- flatten (bool) - ignore the source directory structure (Default: False)
- •
- delete-remote (bool) - clean-up remote directory before deployment (Default: False)
- •
- delete-remote-artifacts (bool) - delete remote artifacts when the build is deleted (Default: False)
- •
- fail-no-files (bool) - fail build if there are no files (Default: False)
- •
- groovy-script (str) - execute a Groovy script before a build is deleted
- •
- deploy-if-fail (bool) -- Deploy if the build is failed (Default: False)
Example:
publishers: - artifact-deployer: entries: - files: '*.tar.gz' basedir: '/opt/data' excludes: '*tmp*' remote: '/home/test/' flatten: true delete-remote: true delete-remote-artifacts: true fail-no-files: true groovy-script: 'print 123' deploy-if-fail: true
- blame-upstream
- Notify upstream commiters when build fails Requires the Jenkins Blame upstream commiters Plugin. Example:
publishers: - blame-upstream
- build-publisher
- This plugin allows records from one Jenkins to be published on another Jenkins. Requires the Jenkins Build Publisher Plugin.
- Parameters
- servers (str) -- Specify the servers where to publish
Example:
publishers: - build-publisher: name: servername publish-unstable-builds: true publish-failed-builds: true days-to-keep: -1 num-to-keep: -1 artifact-days-to-keep: -1 artifact-num-to-keep: -1
- publishers.build_trends_publisher(plugin_name, xml_element, data)
- Helper to create various trend publishers.
- campfire
- Send build notifications to Campfire rooms. Requires the Jenkins Campfire Plugin. Campfire notifications global default values must be configured for the Jenkins instance. Default values will be used if no specific values are specified for each job, so all config params are optional.
- Parameters
- •
- subdomain (str) -- override the default campfire subdomain
- •
- token (str) -- override the default API token
- •
- ssl (bool) -- override the default 'use SSL'
- •
- room (str) -- override the default room name
Example:
publishers: - campfire: subdomain: 'sub' ssl: true token: 'TOKEN' room: 'room'
- checkstyle
- Publish trend reports with Checkstyle. Requires the Jenkins Checkstyle Plugin. The checkstyle component accepts a dictionary with the following values:
- Parameters
- •
- pattern (str) -- report filename pattern
- •
- canRunOnFailed (bool) -- also runs for failed builds (instead of just stable or unstable builds)
- •
- shouldDetectModules (bool) --
- •
- healthy (int) -- sunny threshold
- •
- unHealthy (int) -- stormy threshold
- •
- healthThreshold (str) -- threshold priority for health status (high: only high, normal: high and normal, low: all)
- •
- thresholds (dict) -- .INDENT 2.0
- thresholds
- •
- unstable (dict)
- unstable
- •
- totalAll (int)
- •
- totalHigh (int)
- •
- totalNormal (int)
- •
- totalLow (int)
- •
- failed (dict)
- failed
- •
- totalAll (int)
- •
- totalHigh (int)
- •
- totalNormal (int)
- •
- totalLow (int)
- •
- defaultEncoding (str) -- encoding for parsing or showing files (empty will use platform default)
Example:
publishers: - checkstyle: pattern: '**/checkstyle-result.xml' healthy: 0 unHealthy: 100 healthThreshold: 'high' thresholds: unstable: totalHigh: 10 failed: totalHigh: 1
Full example:
publishers: - checkstyle: pattern: '**/checkstyle-result.xml' canRunOnFailed: true shouldDetectModules: true healthy: 0 unHealthy: 100 healthThreshold: 'high' thresholds: unstable: totalAll: 90 totalHigh: 80 totalNormal: 70 totalLow: 60 failed: totalAll: 90 totalHigh: 80 totalNormal: 70 totalLow: 60 defaultEncoding: 'utf-8'
- cifs
- Upload files via CIFS. Requires the Jenkins Publish over CIFS Plugin.
- Parameters
- •
- site (str) -- name of the cifs site/share
- •
- target (str) -- destination directory
- •
- target-is-date-format (bool) -- whether target is a date format. If true, raw text should be quoted (default false)
- •
- clean-remote (bool) -- should the remote directory be deleted before transferring files (default false)
- •
- source (str) -- source path specifier
- •
- excludes (str) -- excluded file pattern (optional)
- •
- remove-prefix (str) -- prefix to remove from uploaded file paths (optional)
- •
- fail-on-error (bool) -- fail the build if an error occurs (default false).
- •
- flatten (bool) -- only create files on the server, don't create directories (default false).
Example:
publishers: - cifs: site: 'cifs.share' target: 'dest/dir' source: 'base/source/dir/**' remove-prefix: 'base/source/dir' excludes: '**/*.excludedfiletype' flatten: true
- cigame
- This plugin introduces a game where users get points for improving the builds. Requires the Jenkins The Continuous Integration Game plugin. Example:
publishers: - cigame
- claim-build
- Claim build failures Requires the Jenkins Claim Plugin. Example:
publishers: - claim-build
- clone-workspace
- Archive the workspace from builds of one project and reuse them as the SCM source for another project. Requires the Jenkins Clone Workspace SCM Plugin.
- Parameters
- •
- workspace-glob (str) -- Files to include in cloned workspace
- •
- workspace-exclude-glob (str) -- Files to exclude from cloned workspace
- •
- criteria (str) -- Criteria for build to be archived. Can be 'any', 'not failed', or 'successful'. (default: any )
- •
- archive-method (str) -- Choose the method to use for archiving the workspace. Can be 'tar' or 'zip'. (default: tar)
- •
- override-default-excludes (bool) -- Override default ant excludes. (default: false)
Minimal example:
publishers: - clone-workspace
Full example:
publishers: - clone-workspace: criteria: "any" archive-method: "tar" override-default-excludes: false workspace-glob: "**/*.zip" workspace-exclude-glob: "**/*.tgz"
- cloverphp
- Capture code coverage reports from PHPUnit Requires the Jenkins Clover PHP Plugin. Your job definition should pass to PHPUnit the --coverage-clover option pointing to a file in the workspace (ex: clover-coverage.xml). The filename has to be filled in the xml-location field.
- Parameters
- •
- xml-location (str) -- Path to the coverage XML file generated by PHPUnit using --coverage-clover. Relative to workspace. (required)
- •
- html (dict) -- When existent, whether the plugin should generate a HTML report. Note that PHPUnit already provide a HTML report via its --cover-html option which can be set in your builder (optional):
- •
- dir (str): Directory where HTML report will be generated relative
- to workspace. (required in html dict).
- •
- archive (bool): Whether to archive HTML reports (default True).
- •
- metric-targets (list) -- List of metric targets to reach, must be one of healthy, unhealthy and failing. Each metric target can takes two parameters:
- •
- method Target for method coverage
- •
- statement Target for statements coverage
Whenever a metric target is not filled in, the Jenkins plugin can fill in defaults for you (as of v0.3.3 of the plugin the healthy target will have method: 70 and statement: 80 if both are left empty). Jenkins Job Builder will mimic that feature to ensure clean configuration diff.
Minimal example:
# Test for the defaults, only xml-location is required publishers: - cloverphp: xml-location: 'build/clover.xml'
Full example:
# Exercise all options with non defaults values publishers: - cloverphp: xml-location: 'build/clover.xml' html: dir: 'html' archive: false metric-targets: - healthy: method: 80 statement: 90 - unhealthy: method: 40 statement: 50 - failing: method: 10 statement: 20
- cobertura
- Generate a cobertura coverage report. Requires the Jenkins Cobertura Coverage Plugin.
- Parameters
- •
- report-file (str) -- This is a file name pattern that can be used to locate the cobertura xml report files (optional)
- •
- only-stable (bool) -- Include only stable builds (default false)
- •
- fail-no-reports (bool) -- fail builds if no coverage reports are found (default false)
- •
- fail-unhealthy (bool) -- Unhealthy projects will be failed (default false)
- •
- fail-unstable (bool) -- Unstable projects will be failed (default false)
- •
- health-auto-update (bool) -- Auto update threshold for health on successful build (default false)
- •
- stability-auto-update (bool) -- Auto update threshold for stability on successful build (default false)
- •
- zoom-coverage-chart (bool) -- Zoom the coverage chart and crop area below the minimum and above the maximum coverage of the past reports (default false)
- •
- source-encoding (str) -- Override the source encoding (default ASCII)
- •
- targets (dict) -- .INDENT 2.0
- targets
- (packages, files, classes, method, line, conditional)
- •
- healthy (int): Healthy threshold (default 0)
- •
- unhealthy (int): Unhealthy threshold (default 0)
- •
- failing (int): Failing threshold (default 0)
Example:
publishers: - cobertura: report-file: "/reports/cobertura/coverage.xml" only-stable: "true" fail-no-reports: "true" fail-unhealthy: "true" fail-unstable: "true" health-auto-update: "true" stability-auto-update: "true" zoom-coverage-chart: "true" source-encoding: "Big5" targets: - files: healthy: 10 unhealthy: 20 failing: 30 - method: healthy: 50 unhealthy: 40 failing: 30
- copy-to-master
- Copy files to master from slave Requires the Jenkins Copy To Slave Plugin.
- Parameters
- •
- includes (list) -- list of file patterns to copy
- •
- excludes (list) -- list of file patterns to exclude
- •
- destination (string) -- absolute path into which the files will be copied. If left blank they will be copied into the workspace of the current job
Example:
publishers: - copy-to-master: includes: - file1 - file2*.txt excludes: - file2bad.txt
- coverage
- WARNING: The coverage function is deprecated. Instead, use the cobertura function to generate a cobertura coverage report. Requires the Jenkins Cobertura Coverage Plugin. Example:
publishers: - coverage
- cppcheck
- Cppcheck result publisher Requires the Jenkins Cppcheck Plugin.
- Parameters
- pattern (str) -- file pattern for cppcheck xml report
for more optional parameters see the example Example:
publishers: - cppcheck: pattern: "**/cppcheck.xml" # the rest is optional # build status (new) error count thresholds thresholds: unstable: 5 new-unstable: 5 failure: 7 new-failure: 3 # severities which count towards the threshold, default all true severity: error: true warning: true information: false graph: xysize: [500, 200] # which errors to display, default only sum display: sum: false error: true
- description-setter
- This plugin sets the description for each build, based upon a RegEx test of the build log file. Requires the Jenkins Description Setter Plugin.
- Parameters
- •
- regexp (str) -- A RegEx which is used to scan the build log file
- •
- regexp-for-failed (str) -- A RegEx which is used for failed builds (optional)
- •
- description (str) -- The description to set on the build (optional)
- •
- description-for-failed (str) -- The description to set on the failed builds (optional)
- •
- set-for-matrix (bool) -- Also set the description on a multi-configuration build (Default False)
Example:
publishers: - description-setter: regexp: ".*(<a href=.*a>)" regexp-for-failed: ".*(<a href=.*a>)" description: "some description" description-for-failed: "another description" set-for-matrix: true
- doxygen
- This plugin parses the Doxygen descriptor (Doxyfile) and provides a link to the generated Doxygen documentation. Requires the Jenkins Doxygen Plugin.
- Parameters
- •
- doxyfile (str) -- The doxyfile path
- •
- keepall (bool) -- Retain doxygen generation for each successful build (default: false)
- •
- folder (str) -- Folder where you run doxygen (default: '')
Example:
publishers: - doxygen: doxyfile: "Doxyfile" keepall: false folder: "build"
- Email notifications on build failure.
- Parameters
- •
- recipients (str) -- Recipient email addresses
- •
- notify-every-unstable-build (bool) -- Send an email for every unstable build (default true)
- •
- send-to-individuals (bool) -- Send an email to the individual who broke the build (default false)
Example:
publishers: - email: recipients: breakage@example.com
- email-ext
- Extend Jenkin's built in email notification Requires the Jenkins Email-ext Plugin.
- Parameters
- •
- recipients (str) -- Comma separated list of emails
- •
- reply-to (str) -- Comma separated list of emails that should be in the Reply-To header for this project (default $DEFAULT_REPLYTO)
- •
- content-type (str) -- The content type of the emails sent. If not set, the Jenkins plugin uses the value set on the main configuration page. Possible values: 'html', 'text' or 'default' (default 'default')
- •
- subject (str) -- Subject for the email, can include variables like ${BUILD_NUMBER} or even groovy or javascript code
- •
- body (str) -- Content for the body of the email, can include variables like ${BUILD_NUMBER}, but the real magic is using groovy or javascript to hook into the Jenkins API itself
- •
- attach-build-log (bool) -- Include build log in the email (default false)
- •
- attachments (str) -- pattern of files to include as attachment (optional)
- •
- always (bool) -- Send an email for every result (default false)
- •
- unstable (bool) -- Send an email for an unstable result (default false)
- •
- first-failure (bool) -- Send an email for just the first failure (default false)
- •
- not-built (bool) -- Send an email if not built (default false)
- •
- aborted (bool) -- Send an email if the build is aborted (default false)
- •
- regression (bool) -- Send an email if there is a regression (default false)
- •
- failure (bool) -- Send an email if the build fails (default true)
- •
- second-failure (bool) -- Send an email for the second failure (default false)
- •
- improvement (bool) -- Send an email if the build improves (default false)
- •
- still-failing (bool) -- Send an email if the build is still failing (default false)
- •
- success (bool) -- Send an email for a successful build (default false)
- •
- fixed (bool) -- Send an email if the build is fixed (default false)
- •
- still-unstable (bool) -- Send an email if the build is still unstable (default false)
- •
- pre-build (bool) -- Send an email before the build (default false)
- •
- presend-script (str) -- A Groovy script executed prior sending the mail. (default '')
- •
- matrix-trigger (str) -- If using matrix projects, when to trigger
- matrix-trigger values
- •
- both
- •
- only-parent
- •
- only-configurations
- •
- send-to (list) -- list of recipients from the predefined groups
- send-to values
- •
- developers (disabled by default)
- •
- requester (disabled by default)
- •
- culprits (disabled by default)
- •
- recipients (enabled by default)
Example:
publishers: - email-ext: recipients: foo@example.com, bar@example.com reply-to: foo@example.com content-type: html subject: Subject for Build ${BUILD_NUMBER} body: The build has finished attach-build-log: false attachments: "*/foo*.log" always: true unstable: true first-failure: true not-built: true aborted: true regression: true failure: true second-failure: true improvement: true still-failing: true success: true fixed: true still-unstable: true pre-build: true matrix-trigger: only-configurations presend-script: "cancel=true" send-to: - developers - requester - culprits - recipients
- emotional-jenkins
- Emotional Jenkins. Requires the Jenkins Emotional Jenkins Plugin. Example:
publishers: - emotional-jenkins
- fingerprint
- Fingerprint files to track them across builds
- Parameters
- •
- files (str) -- files to fingerprint, follows the @includes of Ant fileset (default blank)
- •
- record-artifacts (bool) -- fingerprint all archived artifacts (default false)
Example:
publishers: - fingerprint: files: builddir/test*.xml record-artifacts: false
- fitnesse
- Publish Fitnesse test results Requires the Jenkins Fitnesse plugin.
- Parameters
- results (str) -- path specifier for results files
Example:
publishers: - fitnesse: results: "fitnesse-results/**/*.xml"
- ftp
- Upload files via FTP. Requires the Jenkins Publish over FTP Plugin.
- Parameters
- •
- site (str) -- name of the ftp site
- •
- target (str) -- destination directory
- •
- target-is-date-format (bool) -- whether target is a date format. If true, raw text should be quoted (default false)
- •
- clean-remote (bool) -- should the remote directory be deleted before transferring files (default false)
- •
- source (str) -- source path specifier
- •
- excludes (str) -- excluded file pattern (optional)
- •
- remove-prefix (str) -- prefix to remove from uploaded file paths (optional)
- •
- fail-on-error (bool) -- fail the build if an error occurs (default false).
- •
- flatten (bool) -- only create files on the server, don't create directories (default false).
Example:
publishers: - ftp: site: 'ftp.example.com' target: 'dest/dir' source: 'base/source/dir/**' remove-prefix: 'base/source/dir' excludes: '**/*.excludedfiletype' flatten: true
- git
- This plugin will configure the Jenkins Git plugin to push merge results, tags, and/or branches to remote repositories after the job completes. Requires the Jenkins Git Plugin.
- Parameters
- •
- push-merge (bool) -- push merges back to the origin specified in the pre-build merge options (Default: False)
- •
- push-only-if-success (bool) -- Only push to remotes if the build succeeds - otherwise, nothing will be pushed. (Default: True)
- •
- tags (list) -- tags to push at the completion of the build
- tag
- •
- remote (str) remote repo name to push to (Default: 'origin')
- •
- name (str) name of tag to push
- •
- message (str) message content of the tag
- •
- create-tag (bool) whether or not to create the tag after the build, if this is False then the tag needs to exist locally (Default: False)
- •
- update-tag (bool) whether to overwrite a remote tag or not (Default: False)
- •
- branches (list) -- branches to push at the completion of the build
- branch
- •
- remote (str) remote repo name to push to (Default: 'origin')
- •
- name (str) name of remote branch to push to
- •
- notes (list) -- notes to push at the completion of the build
- note
- •
- remote (str) remote repo name to push to (Default: 'origin')
- •
- message (str) content of the note
- •
- namespace (str) namespace of the note (Default: master)
- •
- replace-note (bool) whether to overwrite a note or not (Default: False)
Example:
publishers: - git: push-merge: true push-only-if-success: false tags: - tag: remote: tagremotename name: tagname message: "some tag message" create-tag: true update-tag: true branches: - branch: remote: branchremotename name: "some/branch" notes: - note: remote: remotename message: "some note to push" namespace: commits replace-note: true
- github-notifier
- Set build status on Github commit. Requires the Jenkins Github Plugin. Example:
publishers: - github-notifier
- groovy-postbuild
- Execute a groovy script. Requires the Jenkins Groovy Postbuild Plugin
- Parameter
- the groovy script to execute
Example:
publishers: - groovy-postbuild: "manager.buildFailure()"
- html-publisher
- This plugin publishes HTML reports. Requires the Jenkins HTML Publisher Plugin.
- Parameters
- •
- name (str) -- Report name
- •
- dir (str) -- HTML directory to archive
- •
- files (str) -- Specify the pages to display
- •
- keep-all (bool) -- keep HTML reports for each past build (Default False)
- •
- allow-missing (bool) -- Allow missing HTML reports (Default False)
Example:
publishers: - html-publisher: name: "some name" dir: "path/" files: "index.html" keep-all: true allow-missing: true
- ircbot
- ircbot enables Jenkins to send build notifications via IRC and lets you interact with Jenkins via an IRC bot. Requires the Jenkins IRC Plugin.
- Parameters
- •
- strategy (string) -- When to send notifications
- strategy values
- •
- all always (default)
- •
- any-failure on any failure_and_fixed
- •
- failure-and-fixed on failure and fixes
- •
- new-failure-and-fixed on new failure and fixes
- •
- statechange-only only on state change
- •
- notify-start (bool) -- Whether to send notifications to channels when a build starts (default: false)
- •
- notify-committers (bool) -- Whether to send notifications to the users that are suspected of having broken this build (default: false)
- •
- notify-culprits (bool) -- Also send notifications to 'culprits' from previous unstable/failed builds (default: false)
- •
- notify-upstream (bool) -- Whether to send notifications to upstream committers if no committers were found for a broken build (default: false)
- •
- notify-fixers (bool) -- Whether to send notifications to the users that have fixed a broken build (default: false)
- •
- message-type (string) -- Channel Notification Message.
- message-type values
- •
- summary-scm for summary and SCM changes (default)
- •
- summary for summary only
- •
- summary-params for summary and build parameters
- •
- summary-scm-fail for summary, SCM changes, failures)
- •
- channels (list) -- .INDENT 2.0
- list channels definitions
- If empty, it takes channel from Jenkins configuration. (default: empty) WARNING: the IRC plugin requires the channel to be configured in the system wide configuration or the jobs will fail to emit notifications to the channel
- Channel
- •
- name (str) Channel name
- •
- password (str) Channel password (optional)
- •
- notify-only (bool) Set to true if you want to disallow bot commands (default: false)
- •
- matrix-notifier (string) -- .INDENT 2.0
- notify for matrix projects
- instant-messaging-plugin injects an additional field in the configuration form whenever the project is a multi-configuration project
- matrix-notifier values
- •
- all
- •
- only-configurations (default)
- •
- only-parent
Example:
publishers: - ircbot: strategy: all notify-start: false notify-committers: false notify-culprits: false notify-upstream: false notify-fixers: false message-type: summary-scm channels: - name: '#jenkins-channel1' password: secrete notify-only: false - name: '#jenkins-channel2' notify-only: true matrix-notifier: only-configurations
- jabber
- Integrates Jenkins with the Jabber/XMPP instant messaging protocol Requires the Jenkins Jabber Plugin.
- Parameters
- •
- notify-on-build-start (bool) -- Whether to send notifications to channels when a build starts (default false)
- •
- notify-scm-committers (bool) -- Whether to send notifications to the users that are suspected of having broken this build (default false)
- •
- notify-scm-culprits (bool) -- Also send notifications to 'culprits' from previous unstable/failed builds (default false)
- •
- notify-upstream-committers (bool) -- Whether to send notifications to upstream committers if no committers were found for a broken build (default false)
- •
- notify-scm-fixers (bool) -- Whether to send notifications to the users that have fixed a broken build (default false)
- •
- group-targets (list) -- List of group targets to notify
- •
- individual-targets (list) -- List of individual targets to notify
- •
- strategy (dict) -- When to send notifications (default all)
- strategy values
- •
- all -- Always
- •
- failure -- On any failure
- •
- failure-fixed -- On failure and fixes
- •
- change -- Only on state change
- •
- message (dict) -- Channel notification message (default summary-scm)
- message values
- •
- summary-scm -- Summary + SCM changes
- •
- summary -- Just summary
- •
- summary-build -- Summary and build parameters
- •
- summary-scm-fail -- Summary, SCM changes, and failed tests
Example:
publishers: - jabber: notify-on-build-start: true group-targets: - "foo-room@conference-2-fooserver.foo.com" individual-targets: - "foo-user@conference-2-fooserver.foo.com" strategy: all message: summary-scm
- jacoco
- Generate a JaCoCo coverage report. Requires the Jenkins JaCoCo Plugin.
- Parameters
- •
- exec-pattern (str) -- This is a file name pattern that can be used to locate the jacoco report files (default **/**.exec)
- •
- class-pattern (str) -- This is a file name pattern that can be used to locate class files (default **/classes)
- •
- source-pattern (str) -- This is a file name pattern that can be used to locate source files (default **/src/main/java)
- •
- update-build-status (bool) -- Update the build according to the results (default False)
- •
- inclusion-pattern (str) -- This is a file name pattern that can be used to include certain class files (optional)
- •
- exclusion-pattern (str) -- This is a file name pattern that can be used to exclude certain class files (optional)
- •
- targets (dict) -- .INDENT 2.0
- targets
- (instruction, branch, complexity, line, method, class)
- •
- healthy (int): Healthy threshold (default 0)
- •
- unhealthy (int): Unhealthy threshold (default 0)
Example:
publishers: - jacoco: exec-pattern: "**/**.exec" class-pattern: "**/classes" source-pattern: "**/src/main/java" status-update: true targets: - branch: healthy: 10 unhealthy: 20 - method: healthy: 50 unhealthy: 40
- jira
- Update relevant JIRA issues Requires the Jenkins JIRA Plugin Example:
publishers: - jira
- join-trigger
- Trigger a job after all the immediate downstream jobs have completed
- Parameters
- projects (list) -- list of projects to trigger
Example:
publishers: - join-trigger: projects: - project-one - project-two
- junit
- Publish JUnit test results.
- Parameters
- •
- results (str) -- results filename
- •
- keep-long-stdio (bool) -- Retain long standard output/error in test results (default true).
- •
- test-stability (bool) -- Add historical information about test results stability (default false). Requires the Jenkins Test stability Plugin.
Minimal example using defaults:
publishers: - junit: results: nosetests.xml
Full example:
publishers: - junit: results: nosetests-example.xml keep-long-stdio: false test-stability: true
- logparser
- Requires the Jenkins Log Parser Plugin.
- Parameters
- •
- parse-rules (str) -- full path to parse rules
- •
- unstable-on-warning (bool) -- mark build unstable on warning
- •
- fail-on-error (bool) -- mark build failed on error
Example:
publishers: - logparser: parse-rules: "/path/to/parserules" unstable-on-warning: true fail-on-error: true
- maven-deploy
- Deploy artifacts to Maven repository.
- Parameters
- •
- id (str) -- Repository ID
- •
- url (str) -- Repository URL
- •
- unique-version (bool) -- Assign unique versions to snapshots (default true)
- •
- deploy-unstable (bool) -- Deploy even if the build is unstable (default false)
Example:
publishers: - maven-deploy: id: example url: http://repo.example.com/maven2/ unique-version: true deploy-unstable: false
- performance
- Publish performance test results from jmeter and junit. Requires the Jenkins Performance Plugin.
- Parameters
- •
- failed-threshold (int) -- Specify the error percentage threshold that set the build failed. A negative value means don't use this threshold (default 0)
- •
- unstable-threshold (int) -- Specify the error percentage threshold that set the build unstable. A negative value means don't use this threshold (default 0)
- •
- report (dict) -- .INDENT 2.0
- (jmeter or junit)
- (dict or str): Specify a custom report file (optional; jmeter default **/ .jtl, junit default */TEST-*.xml)
Examples:
publishers: - performance: failed-threshold: 85 unstable-threshold: -1 report: - jmeter: "/special/file.jtl" - junit: "/special/file.xml" publishers: - performance: failed-threshold: 85 unstable-threshold: -1 report: - jmeter - junit publishers: - performance: failed-threshold: 85 unstable-threshold: -1 report: - jmeter: "/special/file.jtl" - junit: "/special/file.xml" - jmeter - junit
- pipeline
- Specify a downstream project in a pipeline. Requires the Jenkins Build Pipeline Plugin.
- Parameters
- •
- project (str) -- the name of the downstream project
- •
- predefined-parameters (str) -- parameters to pass to the other job (optional)
- •
- current-parameters (bool) -- Whether to include the parameters passed to the current build to the triggered job (optional)
Example:
publishers: - pipeline: project: test_project current-parameters: true predefined-parameters: foo=bar
You can build pipeline jobs that are re-usable in different pipelines by using a job-template to define the pipeline jobs, and variable substitution to specify the name of the downstream job in the pipeline. Job-specific substitutions are useful here (see project). See 'samples/pipeline.yaml' for an example pipeline implementation.
- plot
- Plot provides generic plotting (or graphing). Requires the Jenkins Plot Plugin.
- Parameters
- •
- title (str) -- title for the graph (default: '')
- •
- yaxis (str) -- title of Y axis
- •
- group (str) -- name of the group to which the plot belongs
- •
- num-builds (int) -- number of builds to plot across (default: plot all builds)
- •
- style (str) -- Specifies the graph style of the plot Can be: area, bar, bar3d, line, line3d, stackedArea, stackedbar, stackedbar3d, waterfall (default: 'line')
- •
- use-description (bool) -- When false, the X-axis labels are formed using build numbers and dates, and the corresponding tooltips contain the build descriptions. When enabled, the contents of the labels and tooltips are swapped, with the descriptions used as X-axis labels and the build number and date used for tooltips. (default: False)
- •
- csv-file-name (str) -- Use for choosing the file name in which the data will be persisted. If none specified and random name is generated as done in the Jenkins Plot plugin. (default: random generated .csv filename, same behaviour as the Jenkins Plot plugin)
- •
- series (list) -- list data series definitions
- Serie
- •
- file (str) : files to include
- •
- inclusion-flag filtering mode for CSV files. Possible values are:
- •
- off (default)
- •
- include-by-string
- •
- exclude-by-string
- •
- include-by-column
- •
- exclude-by-column
- •
- exclude (str) : exclude pattern for CSV file.
- •
- url (str) : for 'csv' and 'xml' file types used when you click on a point (default: empty)
- •
- display-table (bool) : for 'csv' file type if true, original CSV will be shown above plot (default: False)
- •
- label (str) : used by 'properties' file type Specifies the legend label for this data series. (default: empty)
- •
- format (str) : Type of file where we get datas. Can be: properties, csv, xml
- •
- xpath-type (str) : The result type of the expression must be supplied due to limitations in the java.xml.xpath parsing. The result can be: node, nodeset, boolean, string, or number. Strings and numbers will be converted to double. Boolean will be converted to 1 for true, and 0 for false. (default: 'node')
- •
- xpath (str) : used by 'xml' file type Xpath which selects the values that should be plotted.
Example:
publishers: - plot: - title: MyPlot yaxis: Y group: PlotGroup num-builds: '' style: line use-description: false series: - file: graph-me-second.properties label: MyLabel format: properties - file: graph-me-first.csv url: 'http://srv1' inclusion-flag: 'off' display-table: true format: csv - title: MyPlot2 yaxis: Y group: PlotGroup style: line use-description: false series: - file: graph-me-third.xml url: 'http://srv2' format: xml xpath-type: 'node' xpath: '/*'
- pmd
- Publish trend reports with PMD. Requires the Jenkins PMD Plugin. The PMD component accepts a dictionary with the following values:
- Parameters
- •
- pattern (str) -- Report filename pattern (optional)
- •
- can-run-on-failed (bool) -- Also runs for failed builds, instead of just stable or unstable builds (default false)
- •
- should-detect-modules (bool) -- Determines if Ant or Maven modules should be detected for all files that contain warnings (default false)
- •
- healthy (int) -- Sunny threshold (optional)
- •
- unhealthy (int) -- Stormy threshold (optional)
- •
- health-threshold (str) -- Threshold priority for health status ('low', 'normal' or 'high', defaulted to 'low')
- •
- thresholds (dict) -- Mark build as failed or unstable if the number of errors exceeds a threshold. (optional)
- thresholds
- •
- unstable (dict)
- unstable
- •
- total-all (int)
- •
- total-high (int)
- •
- total-normal (int)
- •
- total-low (int)
- •
- new-all (int)
- •
- new-high (int)
- •
- new-normal (int)
- •
- new-low (int)
- •
- failed (dict)
- failed
- •
- total-all (int)
- •
- total-high (int)
- •
- total-normal (int)
- •
- total-low (int)
- •
- new-all (int)
- •
- new-high (int)
- •
- new-normal (int)
- •
- new-low (int)
- •
- default-encoding (str) -- Encoding for parsing or showing files (optional)
- •
- do-not-resolve-relative-paths (bool) -- (default false)
- •
- dont-compute-new (bool) -- If set to false, computes new warnings based on the reference build (default true)
- •
- use-stable-build-as-reference (bool) -- The number of new warnings will be calculated based on the last stable build, allowing reverts of unstable builds where the number of warnings was decreased. (default false)
- •
- use-delta-values (bool) -- If set then the number of new warnings is calculated by subtracting the total number of warnings of the current build from the reference build. (default false)
Example:
publishers: - pmd: pattern: '**/pmd-result.xml' healthy: 0 unhealthy: 100 health-threshold: 'high' thresholds: unstable: total-high: 10 failed: total-high: 1
Full example:
publishers: - pmd: pattern: '**/pmd-result.xml' can-run-on-failed: true should-detect-modules: true healthy: 0 unhealthy: 100 health-threshold: 'high' thresholds: unstable: total-all: 90 total-high: 80 total-normal: 70 total-low: 60 failed: total-all: 90 total-high: 80 total-normal: 70 total-low: 60 default-encoding: 'utf-8'
- post-tasks
- Adds support to post build task plugin Requires the Jenkins Post Build Task plugin.
- Parameters
- •
- task (dict) -- Post build task definition
- •
- task[matches] (list) -- list of matches when to run the task
- •
- task[matches][*] (dict) -- match definition
- •
- task[matches][*][log-text] (str) -- text to match against the log
- •
- task[matches][*][operator] (str) -- operator to apply with the next match
- task[matches][*][operator] values (default 'AND')
- •
- AND
- •
- OR
- •
- task[escalate-status] (bool) -- Escalate the task status to the job (default 'false')
- •
- task[run-if-job-successful] (bool) -- Run only if the job was successful (default 'false')
- •
- task[script] (str) -- Shell script to run (default '')
Example:
publishers: - post-tasks: - matches: - log-text: line to match operator: AND - log-text: line to match operator: OR - log-text: line to match operator: AND escalate-status: false run-if-job-successful:false script: | echo "Here goes the task script"
- postbuildscript
- Executes additional builders, script or Groovy after the build is complete. Requires the Jenkins Post Build Script plugin.
- Parameters
- •
- generic-script (list) -- Paths to Batch/Shell scripts
- •
- groovy-script (list) -- Paths to Groovy scripts
- •
- groovy (list) -- Inline Groovy
- •
- builders (list) -- Any supported builders, see builders.
- •
- onsuccess (bool) -- Scripts and builders are run only if the build succeed (default False)
- •
- onfailure (bool) -- Scripts and builders are run only if the build fail (default True)
- •
- execute-on (str) -- For matrix projects, scripts can be run after each axis is built ( axes), after all axis of the matrix are built ( matrix) or after each axis AND the matrix are built ( both).
The onsuccess and onfailure options are confusing. If you want the post build to always run regardless of the build status, you should set them both to false. Example:
publishers: - postbuildscript: generic-script: - '/tmp/one.sh' - '/tmp/two.sh' groovy-script: - '/tmp/one.groovy' - '/tmp/two.groovy' groovy: - "/** This is some inlined groovy */" - "/** Some more inlined groovy */" onsuccess: False onfailure: True
You can also execute builders:
publishers: - postbuildscript: builders: - shell: 'echo "Shell execution"' - ant: 'ant_target'
Run once after the whole matrix (all axes) is built:
publishers: - postbuildscript: execute-on: 'matrix' builders: - shell: 'echo "Shell execution"'
- robot
- Adds support for the Robot Framework Plugin Requires the Jenkins Robot Framework Plugin.
- Parameters
- •
- output-path (str) -- Path to directory containing robot xml and html files relative to build workspace. (default '')
- •
- log-file-link (str) -- Name of log or report file to be linked on jobs front page (default '')
- •
- report-html (str) -- Name of the html file containing robot test report (default 'report.html')
- •
- log-html (str) -- Name of the html file containing detailed robot test log (default 'log.html')
- •
- output-xml (str) -- Name of the xml file containing robot output (default 'output.xml')
- •
- pass-threshold (str) -- Minimum percentage of passed tests to consider the build successful (default 0.0)
- •
- unstable-threshold (str) -- Minimum percentage of passed test to consider the build as not failed (default 0.0)
- •
- only-critical (bool) -- Take only critical tests into account when checking the thresholds (default true)
- •
- other-files (list) -- list other files to archive (default '')
Example:
- publishers: - robot: output-path: reports/robot log-file-link: report.html report-html: report.html log-html: log.html output-xml: output.xml pass-threshold: 80.0 unstable-threshold: 60.0 only-critical: false other-files: - extra-file1.html - extra-file2.txt
- ruby-metrics
- Rcov plugin parses rcov html report files and shows it in Jenkins with a trend graph. Requires the Jenkins Ruby metrics plugin.
- Parameters
- •
- report-dir (str) -- Relative path to the coverage report directory
- •
- targets (dict) -- .INDENT 2.0
- targets
- (total-coverage, code-coverage)
- •
- healthy (int): Healthy threshold
- •
- unhealthy (int): Unhealthy threshold
- •
- unstable (int): Unstable threshold
Example:
publishers: - ruby-metrics: report-dir: "coverage/rcov" target: - total-coverage: healthy: 80 unhealthy: 0 unstable: 0 - code-coverage: healthy: 80 unhealthy: 0 unstable: 0
- scp
- Upload files via SCP Requires the Jenkins SCP Plugin.
- Parameters
- •
- site (str) -- name of the scp site
- •
- target (str) -- destination directory
- •
- source (str) -- source path specifier
- •
- keep-hierarchy (bool) -- keep the file hierarchy when uploading (default false)
- •
- copy-after-failure (bool) -- copy files even if the job fails (default false)
- •
- copy-console (bool) -- copy the console log (default false); if specified, omit 'target'
Example:
publishers: - scp: site: 'example.com' files: - target: 'dest/dir' source: 'base/source/dir/**' keep-hierarchy: true copy-after-failure: true
- sitemonitor
- This plugin checks the availability of an url. It requires the sitemonitor plugin.
- Parameters
- sites (list) -- List of URLs to check
Example:
publishers: - sitemonitor: sites: - url: http://foo.example.com - url: http://bar.example.com:8080/
- sloccount
- Generates the trend report for SLOCCount Requires the Jenkins SLOCCount Plugin.
- Parameters
- •
- report-files (str) -- Setting that specifies the generated raw SLOCCount report files. Be sure not to include any non-report files into this pattern. The report files must have been generated by sloccount using the "--wide --details" options. (default: '**/sloccount.sc')
- •
- charset (str) -- The character encoding to be used to read the SLOCCount result files. (default: 'UTF-8')
Example:
publishers: - sloccount: report-files: sloccount.sc charset: UTF-8
- sonar
- Sonar plugin support. Requires the Jenkins Sonar Plugin.
- Parameters
- •
- jdk (str) -- JDK to use (inherited from the job if omitted). (optional)
- •
- branch (str) -- branch onto which the analysis will be posted (optional)
- •
- language (str) -- source code language (optional)
- •
- maven-opts (str) -- options given to maven (optional)
- •
- additional-properties (str) -- sonar analysis parameters (optional)
- •
- skip-global-triggers (dict) -- .INDENT 2.0
- Triggers
- •
- skip-when-scm-change (bool): skip analysis when build triggered by scm
- •
- skip-when-upstream-build (bool): skip analysis when build triggered by an upstream build
- •
- skip-when-envvar-defined (str): skip analysis when the specified environment variable is set to true
This publisher supports the post-build action exposed by the Jenkins Sonar Plugin, which is triggering a Sonar Analysis with Maven. Example:
publishers: - sonar: jdk: MyJdk branch: myBranch language: java maven-opts: -DskipTests additional-properties: -DsonarHostURL=http://example.com/ skip-global-triggers: skip-when-scm-change: true skip-when-upstream-build: true skip-when-envvar-defined: SKIP_SONAR
- ssh
- Upload files via SCP. Requires the Jenkins Publish over SSH Plugin.
- Parameters
- •
- site (str) -- name of the ssh site
- •
- target (str) -- destination directory
- •
- target-is-date-format (bool) -- whether target is a date format. If true, raw text should be quoted (default false)
- •
- clean-remote (bool) -- should the remote directory be deleted before transferring files (default false)
- •
- source (str) -- source path specifier
- •
- command (str) -- a command to execute on the remote server (optional)
- •
- timeout (int) -- timeout in milliseconds for the Exec command (optional)
- •
- use-pty (bool) -- run the exec command in pseudo TTY (default false)
- •
- excludes (str) -- excluded file pattern (optional)
- •
- remove-prefix (str) -- prefix to remove from uploaded file paths (optional)
- •
- fail-on-error (bool) -- fail the build if an error occurs (default false).
- •
- always-publish-from-master (bool) -- transfer the files through the master before being sent to the remote server (defaults false)
- •
- flatten (bool) -- only create files on the server, don't create directories (default false).
Example:
publishers: - 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 flatten: true
- stash
- This plugin will configure the Jenkins Stash Notifier plugin to notify Atlassian Stash after job completes. Requires the Jenkins StashNotifier Plugin.
- Parameters
- •
- url (string) -- Base url of Stash Server (Default: "")
- •
- username (string) -- Username of Stash Server (Default: "")
- •
- password (string) -- Password of Stash Server (Default: "")
- •
- ignore-ssl (bool) -- Ignore unverified SSL certificate (Default: False)
- •
- commit-sha1 (string) -- Commit SHA1 to notify (Default: "")
- •
- include-build-number (bool) -- Include build number in key (Default: False)
Example:
publishers: - stash: url: "https://mystash" username: a password: b ignore-ssl: true commit-sha1: c include-build-number: true
- tap
- Adds support to TAP test result files Requires the Jenkins TAP Plugin.
- Parameters
- •
- results (str) -- TAP test result files
- •
- fail-if-no-results (bool) -- Fail if no result (default False)
- •
- failed-tests-mark-build-as-failure (bool) -- Mark build as failure if test fails (default False)
- •
- output-tap-to-console (bool) -- Output tap to console (default True)
- •
- enable-subtests (bool) -- Enable subtests (Default True)
- •
- discard-old-reports (bool) -- Discard old reports (Default False)
- •
- todo-is-failure (bool) -- Handle TODO's as failures (Default True)
Example:
publishers: - tap: results: puiparts.tap todo-is-failure: false
- testng
- This plugin publishes TestNG test reports. Requires the Jenkins TestNG Results Plugin.
- Parameters
- •
- pattern (str) -- filename pattern to locate the TestNG XML report files
- •
- escape-test-description (bool) -- escapes the description string associated with the test method while displaying test method details (Default True)
- •
- escape-exception-msg (bool) -- escapes the test method's exception messages. (Default True)
Example:
publishers: - testng: pattern: "**/target/surefire-reports/testng-results.xml" escape-test-description: false escape-exception-msg: true
- text-finder
- This plugin lets you search keywords in the files you specified and additionally check build status Requires the Jenkins Text-finder Plugin.
- Parameters
- •
- regexp (str) -- Specify a regular expression
- •
- fileset (str) -- Specify the path to search
- •
- also-check-console-output (bool) -- Search the console output (default False)
- •
- succeed-if-found (bool) -- Force a build to succeed if a string was found (default False)
- •
- unstable-if-found (bool) -- Set build unstable instead of failing the build (default False)
Example:
publishers: - text-finder: regexp: "some string" fileset: "file.txt" also-check-console-output: true succeed-if-found: false unstable-if-found: false
- trigger
- Trigger non-parametrised builds of other jobs.
- Parameters
- •
- project (str) -- name of the job to trigger
- •
- threshold (str) -- when to trigger the other job (default 'SUCCESS'), alternatives: SUCCESS, UNSTABLE, FAILURE
Example:
publishers: - trigger: project: other_job threshold: SUCCESS
- trigger-parameterized-builds
- Trigger parameterized builds of other jobs. Requires the Jenkins Parameterized Trigger Plugin.
- Parameters
- •
- project (str) -- name of the job to trigger
- •
- predefined-parameters (str) -- parameters to pass to the other job (optional)
- •
- current-parameters (bool) -- Whether to include the parameters passed to the current build to the triggered job (optional)
- •
- svn-revision (bool) -- Pass svn revision to the triggered job (optional)
- •
- git-revision (bool) -- Pass git revision to the other job (optional)
- •
- condition (str) -- when to trigger the other job (default 'ALWAYS')
- •
- property-file (str) -- Use properties from file (optional)
- •
- fail-on-missing (bool) -- Blocks the triggering of the downstream jobs if any of the files are not found in the workspace (default 'False')
- •
- restrict-matrix-project (str) -- Filter that restricts the subset of the combinations that the downstream project will run (optional)
Example:
publishers: - trigger-parameterized-builds: - project: other_job, foo, bar predefined-parameters: foo=bar - project: other_job1, other_job2 predefined-parameters: BUILD_NUM=${BUILD_NUMBER} property-file: version.prop fail-on-missing: true - project: yet_another_job predefined-parameters: foo=bar git-revision: true restrict-matrix-project: label=="x86"
- valgrind
- This plugin publishes Valgrind Memcheck XML results. Requires the Jenkins Valgrind Plugin.
- Parameters
- •
- pattern (str) -- Filename pattern to locate the Valgrind XML report files (required)
- •
- thresholds (dict) -- Mark build as failed or unstable if the number of errors exceeds a threshold. All threshold values are optional.
- thresholds
- •
- unstable (dict)
- unstable
- •
- invalid-read-write (int)
- •
- definitely-lost (int)
- •
- total (int)
- •
- failed (dict)
- failed
- •
- invalid-read-write (int)
- •
- definitely-lost (int)
- •
- total (int)
- •
- fail-no-reports (bool) -- Fail build if no reports are found (default false)
- •
- fail-invalid-reports (bool) -- Fail build if reports are malformed (default false)
- •
- publish-if-aborted (bool) -- Publish results for aborted builds (default false)
- •
- publish-if-failed (bool) -- Publish results for failed builds (default false)
Example:
publishers: - valgrind: pattern: "test.xml" thresholds: unstable: invalid-read-write: 1 definitely-lost: 2 total: 3 failed: invalid-read-write: 4 definitely-lost: 5 total: 6 fail-no-reports: true fail-invalid-reports: true publish-if-aborted: true publish-if-failed: true
- violations
- Publish code style violations. Requires the Jenkins Violations Plugin. The violations component accepts any number of dictionaries keyed by the name of the violations system. The dictionary has the following values:
- Parameters
- •
- min (int) -- sunny threshold
- •
- max (int) -- stormy threshold
- •
- unstable (int) -- unstable threshold
- •
- pattern (str) -- report filename pattern
Any system without a dictionary provided will use default values. Valid systems are:
checkstyle, codenarc, cpd, cpplint, csslint, findbugs,
fxcop, gendarme, jcreport, jslint, pep8, pmd, pylint, simian, stylecop
Example:
publishers: - violations: pep8: min: 0 max: 1 unstable: 1 pattern: '**/pep8.txt'
- warnings
- Generate trend report for compiler warnings in the console log or in log files. Requires the Jenkins Warnings Plugin.
- Parameters
- •
- console-log-parsers (list) -- The parser to use to scan the console log (default '')
- •
- workspace-file-scanners (dict) -- .INDENT 2.0
- workspace-file-scanners
- •
- file-pattern (str) -- Fileset 'includes' setting that
- specifies the files to scan for warnings
- •
- scanner (str) -- The parser to use to scan the files
- provided in workspace-file-pattern (default '')
- •
- files-to-include (str) -- Comma separated list of regular expressions that specifies the files to include in the report (based on their absolute filename). By default all files are included
- •
- files-to-ignore (str) -- Comma separated list of regular expressions that specifies the files to exclude from the report (based on their absolute filename). (default '')
- •
- run-always (bool) -- By default, this plug-in runs only for stable or unstable builds, but not for failed builds. Set to true if the plug-in should run even for failed builds. (default false)
- •
- detect-modules (bool) -- Determines if Ant or Maven modules should be detected for all files that contain warnings. Activating this option may increase your build time since the detector scans the whole workspace for 'build.xml' or 'pom.xml' files in order to assign the correct module names. (default false)
- •
- resolve-relative-paths (bool) -- Determines if relative paths in warnings should be resolved using a time expensive operation that scans the whole workspace for matching files. Deactivate this option if you encounter performance problems. (default false)
- •
- health-threshold-high (int) -- The upper threshold for the build health. If left empty then no health report is created. If the actual number of warnings is between the provided thresholds then the build health is interpolated (default '')
- •
- health-threshold-low (int) -- The lower threshold for the build health. See health-threshold-high. (default '')
- •
- health-priorities (dict) -- Determines which warning priorities should be considered when evaluating the build health (default all-priorities)
- health-priorities values
- •
- priority-high -- Only priority high
- •
- high-and-normal -- Priorities high and normal
- •
- all-priorities -- All priorities
- •
- total-thresholds (dict) -- If the number of total warnings is greater than one of these thresholds then a build is considered as unstable or failed, respectively. (default '')
- total-thresholds
- •
- unstable (dict)
- unstable
- •
- total-all (int)
- •
- total-high (int)
- •
- total-normal (int)
- •
- total-low (int)
- •
- failed (dict)
- failed
- •
- total-all (int)
- •
- total-high (int)
- •
- total-normal (int)
- •
- total-low (int)
- •
- new-thresholds (dict) -- If the specified number of new warnings exceeds one of these thresholds then a build is considered as unstable or failed, respectively. (default '')
- new-thresholds
- •
- unstable (dict)
- unstable
- •
- new-all (int)
- •
- new-high (int)
- •
- new-normal (int)
- •
- new-low (int)
- •
- failed (dict)
- failed
- •
- new-all (int)
- •
- new-high (int)
- •
- new-normal (int)
- •
- new-high (int)
- •
- use-delta-for-new-warnings (bool) -- If set then the number of new warnings is calculated by subtracting the total number of warnings of the current build from the reference build. This may lead to wrong results if you have both fixed and new warnings in a build. If not set, then the number of new warnings is calculated by an asymmetric set difference of the warnings in the current and reference build. This will find all new warnings even if the number of total warnings is decreasing. However, sometimes false positives will be reported due to minor changes in a warning (refactoring of variable of method names, etc.) (default false)
- •
- only-use-stable-builds-as-reference (bool) -- The number of new warnings will be calculated based on the last stable build, allowing reverts of unstable builds where the number of warnings was decreased. (default false)
- •
- default-encoding (str) -- Default encoding when parsing or showing files Leave empty to use default encoding of platform (default '')
Example:
publishers: - warnings: console-log-parsers: - FxCop - CodeAnalysis workspace-file-scanners: - file-pattern: '**/*.out' scanner: 'AcuCobol Compiler - file-pattern: '**/*.warnings' scanner: FxCop files-to-include: '[a-zA-Z]\.java,[a-zA-Z]\.cpp' files-to-ignore: '[a-zA-Z]\.html,[a-zA-Z]\.js' run-always: true detect-modules: true resolve-relative-paths: true health-threshold-high: 50 health-threshold-low: 25 health-priorities: high-and-normal total-thresholds: unstable: total-all: 90 total-high: 90 total-normal: 40 total-low: 30 failed: total-all: 100 total-high: 100 total-normal: 50 total-low: 40 new-thresholds: unstable: new-all: 100 new-high: 50 new-normal: 30 new-low: 10 failed: new-all: 100 new-high: 60 new-normal: 50 new-low: 40 use-delta-for-new-warnings: true only-use-stable-builds-as-reference: true default-encoding: ISO-8859-9
- workspace-cleanup (post-build)
- Requires the Jenkins Workspace Cleanup Plugin. The pre-build workspace-cleanup is available as a wrapper.
- Parameters
- •
- include (list) -- list of files to be included
- •
- exclude (list) -- list of files to be excluded
- •
- dirmatch (bool) -- Apply pattern to directories too (default: false)
- •
- clean-if (list) -- clean depending on build status
- clean-if values
- •
- success (bool) (default: true)
- •
- unstable (bool) (default: true)
- •
- failure (bool) (default: true)
- •
- aborted (bool) (default: true)
- •
- not-built (bool) (default: true)
- •
- fail-build (bool) -- Fail the build if the cleanup fails (default: true)
- •
- clean-parent (bool) -- Cleanup matrix parent workspace (default: false)
Example:
publishers: - workspace-cleanup: include: - "*.zip" clean-if: - success: true - not-built: false
- xml-summary
- Adds support for the Summary Display Plugin Requires the Jenkins Summary Display Plugin.
- Parameters
- files (str) -- Files to parse (default '')
Example:
publishers: - xml-summary: files: '*_summary_report.xml'
- xunit
- Publish tests results. Requires the Jenkins xUnit Plugin.
- Parameters
- •
- thresholdmode (str) -- whether thresholds represents an absolute number of tests or a percentage. Either 'number' or 'percent', will default to 'number' if omitted.
- •
- thresholds (dict) -- list containing the thresholds for both 'failed' and 'skipped' tests. Each entry should in turn have a list of "threshold name: values". The threshold names are 'unstable', 'unstablenew', 'failure', 'failurenew'. Omitting a value will resort on xUnit default value (should be 0).
- •
- types (dict) -- per framework configuration. The key should be one of the internal types we support: 'aunit', 'boosttest', 'checktype', 'cpptest', 'cppunit', 'fpcunit', 'junit', 'mstest', 'nunit', 'phpunit', 'tusar', 'unittest', 'valgrind'. The 'custom' type is not supported.
Each framework type can be configured using the following parameters:
- Parameters
- •
- pattern (str) -- An Ant pattern to look for Junit result files, relative to the workspace root.
- •
- requireupdate (bool) -- fail the build whenever fresh tests results have not been found (default: true).
- •
- deleteoutput (bool) -- delete temporary JUnit files (default: true)
- •
- stoponerror (bool) -- Fail the build whenever an error occur during a result file processing (default: true).
Example:
publishers: - xunit: thresholdmode: 'percent' thresholds: - failed: unstable: 0 unstablenew: 0 failure: 0 failurenew: 0 - skipped: unstable: 0 unstablenew: 0 failure: 0 failurenew: 0 types: - phpunit: pattern: junit.log - cppUnit: pattern: cppunit.log
Reporters¶
Reporters are like publishers but only applicable to Maven projets.- Component: reporters
- Macro
- reporter
- Entry Point
- jenkins_jobs.reporters
Example:
job: name: test_job project-type: maven reporters: - email: recipients: breakage@example.com
- Email notifications on build failure.
- Parameters
- •
- recipients (str) -- Recipient email addresses
- •
- notify-every-unstable-build (bool) -- Send an email for every unstable build (default true)
- •
- send-to-individuals (bool) -- Send an email to the individual who broke the build (default false)
Example:
reporters: - email: recipients: breakage@example.com
SCM¶
The SCM module allows you to specify the source code location for the project. It adds the scm attribute to the Job definition, which accepts any number of scm definitions.- Component: scm
- Macro
- scm
- Entry Point
- jenkins_jobs.scm
The scm module allows referencing multiple repositories in a Jenkins job. Note: Adding more than one scm definition requires the Jenkins Multiple SCMs plugin.
- Example of multiple repositories in a single job:
- scm: name: first-scm scm: - git: url: ssh://jenkins@review.openstack.org:29418/first.git branches: - origin/master - scm: name: second-scm scm: - git: url: ssh://jenkins@review.openstack.org:29418/second.git branches: - origin/master - scm: name: first-and-second scm: - first-scm - second-scm - job: name: my-job scm: - first-and-second
- git
- Specifies the git SCM repository for this job. Requires the Jenkins Git Plugin.
- Parameters
- •
- url (str) -- URL of the git repository
- •
- credentials-id (str) -- ID of credentials to use to connect (optional)
- •
- refspec (str) -- refspec to fetch (default '+refs/heads/*:refs/remotes/remoteName/*')
- •
- name (str) -- name to fetch (default 'origin')
- •
- remotes (list(str)) -- list of remotes to set up (optional, only needed if multiple remotes need to be set up)
- Remote
- •
- url (string) - url of remote repo
- •
- refspec (string) - refspec to fetch (optional)
- •
- credentials-id - ID of credentials to use to connect
- (optional)
- •
- branches (list(str)) -- list of branch specifiers to build (default '**')
- •
- excluded-users (list(str)) -- list of users to ignore revisions from when polling for changes. (if polling is enabled, optional)
- •
- included-regions (list(str)) -- list of file/folders to include (optional)
- •
- excluded-regions (list(str)) -- list of file/folders to exclude (optional)
- •
- local-branch (str) -- Checkout/merge to local branch (optional)
- •
- merge (dict) -- .INDENT 2.0
- merge
- •
- remote (string) - name of repo that contains branch to
- merge to (default 'origin')
- •
- branch (string) - name of the branch to merge to
- •
- basedir (str) -- location relative to the workspace root to clone to (default: workspace)
- •
- skip-tag (bool) -- Skip tagging (default false)
- •
- shallow-clone (bool) -- Perform shallow clone (default false)
- •
- prune (bool) -- Prune remote branches (default false)
- •
- clean (bool) -- Clean after checkout (default false)
- •
- fastpoll (bool) -- Use fast remote polling (default false)
- •
- disable-submodules (bool) -- Disable submodules (default false)
- •
- recursive-submodules (bool) -- Recursively update submodules (default false)
- •
- use-author (bool) -- Use author rather than committer in Jenkin's build changeset (default false)
- •
- git-tool (str) -- The name of the Git installation to use (default 'Default')
- •
- reference-repo (str) -- Path of the reference repo to use during clone (optional)
- •
- scm-name (str) -- The unique scm name for this Git SCM (optional)
- •
- wipe-workspace (bool) -- Wipe out workspace before build (default true)
- •
- ignore-notify (bool) -- Ignore notifyCommit URL accesses (default false)
- •
- browser (str) -- what repository browser to use (default '(Auto)')
- •
- browser-url (str) -- url for the repository browser (required if browser is not '(Auto)', no default)
- •
- browser-version (str) -- version of the repository browser (GitLab only, default '0.0')
- •
- project-name (str) -- project name in Gitblit and ViewGit repobrowser (optional)
- •
- choosing-strategy (str) -- Jenkins class for selecting what to build (default 'default')
- •
- git-config-name (str) -- Configure name for Git clone (optional)
- •
- git-config-email (str) -- Configure email for Git clone (optional)
- •
- timeout (str) -- Timeout for git commands in minutes (optional)
- Browser values
- auto
- bitbucketweb
- cgit
- fisheye
- gitblit
- githubweb
- gitlab
- gitoriousweb
- gitweb
- redmineweb
- stash
- viewgit
- Choosing-strategy values
- default
- inverse
- gerrit
Example:
scm: - git: url: https://example.com/project.git branches: - master - stable browser: githubweb browser-url: http://github.com/foo/example.git timeout: 20
- repo
- Specifies the repo SCM repository for this job. Requires the Jenkins Repo Plugin.
- Parameters
- •
- manifest-url (str) -- URL of the repo manifest
- •
- manifest-branch (str) -- The branch of the manifest to use (optional)
- •
- manifest-file (str) -- Initial manifest file to use when initialising (optional)
- •
- manifest-group (str) -- Only retrieve those projects in the manifest tagged with the provided group name (optional)
- •
- destination-dir (str) -- Location relative to the workspace root to clone under (optional)
- •
- repo-url (str) -- custom url to retrieve the repo application (optional)
- •
- mirror-dir (str) -- Path to mirror directory to reference when initialising (optional)
- •
- jobs (int) -- Number of projects to fetch simultaneously (default 0)
- •
- current-branch (bool) -- Fetch only the current branch from the server (default true)
- •
- quiet (bool) -- Make repo more quiet (default true)
- •
- local-manifest (str) -- Contents of .repo/local_manifest.xml, written prior to calling sync (optional)
Example:
scm: - repo: manifest-url: https://example.com/project/ manifest-branch: stable manifest-file: repo.xml manifest-group: drivers destination-dir: build repo-url: https://internal.net/projects/repo mirror-dir: ~/git/project/ jobs: 3 current-branch: false quiet: false local-manifest: | <?xml version="1.0" encoding="UTF-8"?> <manifest> <project path="external/project" name="org/project" remote="gerrit" revision="master" /> </manifest>
- store
- Specifies the Visualworks Smalltalk Store repository for this job. Requires the Jenkins Visualworks Smalltalk Store Plugin.
- Parameters
- •
- script (str) -- name of the Store script to run
- •
- repository (str) -- name of the Store repository
- •
- version-regex (str) -- regular expression that specifies which pundle versions should be considered (optional)
- •
- minimum-blessing (str) -- minimum blessing level to consider (optional)
- •
- parcel-builder-file (str) -- name of the file to generate as input to a later parcel building step (optional - if not specified, then no parcel builder file will be generated)
- •
- pundles (list) -- .INDENT 2.0
- (package or bundle)
- (dict): A package or bundle to check
Example:
scm: - store: script: someStoreScript repository: StoreRepository version-regex: "[0-9]+" minimum-blessing: Integrated parcel-builder-file: parcelBuilderInput pundles: - package: SomePackage - package: AnotherPackage - bundle: SomeBundle
- svn
- Specifies the svn SCM repository for this job.
- Parameters
- •
- url (str) -- URL of the svn repository
- •
- basedir (str) -- location relative to the workspace root to checkout to (default '.')
- •
- workspaceupdater (str) -- optional argument to specify how to update the workspace (default wipeworkspace)
- •
- excluded-users (list(str)) -- list of users to ignore revisions from when polling for changes (if polling is enabled; parameter is optional)
- •
- included-regions (list(str)) -- list of file/folders to include (optional)
- •
- excluded-regions (list(str)) -- list of file/folders to exclude (optional)
- •
- excluded-commit-messages (list(str)) -- list of commit messages to exclude (optional)
- •
- exclusion-revprop-name (str) -- revision svn-property to ignore (optional)
- •
- ignore-property-changes-on-directories (bool) -- ignore svn-property only changes of directories (default false)
- •
- filter-changelog (bool) -- If set Jenkins will apply the same inclusion and exclusion patterns for displaying changelog entries as it does for polling for changes (default false)
- •
- repos (list) -- list of repositories to checkout (optional)
- Repo
- •
- url (str) -- URL for the repository
- •
- basedir (str) -- Location relative to the workspace
- root to checkout to (default '.')
- Workspaceupdater values
- wipeworkspace
- •
- deletes the workspace before checking out
- revertupdate
- •
- do an svn revert then an svn update
- emulateclean
- •
- delete unversioned/ignored files then update
- update
- •
- do an svn update as much as possible
Multiple repos example:
scm: - svn: workspaceupdater: update repos: - url: http://svn.example.com/repo basedir: . - url: http://svn.example.com/repo2 basedir: repo2
Advanced commit filtering example:
scm: - svn: url: http://svn.apache.org/repos/asf/spamassassin/trunk workspaceupdater: wipeworkspace included-regions: - /region1/.*\.cpp - /region2 excluded-regions: - /region3/.*\.jpg - /region4 excluded-users: - user1 - user2 excluded-commit-messages: - test-msg - test-msg2 exclusion-revprop-name: propname filter-changelog: true ignore-property-changes-on-directories: true
- tfs
- Specifies the Team Foundation Server repository for this job. Requires the Jenkins Team Foundation Server Plugin. NOTE: TFS Password must be entered manually on the project if a user name is specified. The password will be overwritten with an empty value every time the job is rebuilt with Jenkins Job Builder.
- Parameters
- •
- server-url (str) -- The name or URL of the team foundation server. If the server has been registered on the machine then it is only necessary to enter the name.
- •
- project-path (str) -- The name of the project as it is registered on the server.
- •
- login (str) -- The user name that is registered on the server. The user name must contain the name and the domain name. Entered as domain\user or user@domain (optional). NOTE: You must enter in at least two slashes for the domain\user format in JJB YAML. It will be rendered normally.
- •
- use-update (str) -- If true, Hudson will not delete the workspace at end of each build. This causes the artifacts from the previous build to remain when a new build starts. (default true)
- •
- local-path (str) -- The folder where all files will be retrieved into. The folder name is a relative path, under the workspace of the current job. (default .)
- •
- workspace (str) -- The name of the workspace under which the source should be retrieved. This workspace is created at the start of a download, and deleted at the end. You can normally omit the property unless you want to name a workspace to avoid conflicts on the server (i.e. when you have multiple projects on one server talking to a Team Foundation Server). (default Hudson-${JOB_NAME}-${NODE_NAME}) The TFS plugin supports the following macros that are replaced in the workspace name:
- •
- ${JOB_NAME} - The name of the job.
- •
- ${USER_NAME} - The user name that the Hudson server or slave is
- running as.
- •
- ${NODE_NAME} - The name of the node/slave that the plugin currently
- is executed on. Note that this is not the hostname, this value is the Hudson configured name of the slave/node.
- •
- ${ENV} - The environment variable that is set on the master or slave.
- •
- web-access (dict) -- Adds links in "changes" views within Jenkins to an external system for browsing the details of those changes. The "Auto" selection attempts to infer the repository browser from other jobs, if supported by the SCM and a job with matching SCM details can be found. (optional, default Auto).
- web-access value
- •
- web-url -- Enter the URL to the TSWA server. The plugin will strip the last path (if any) of the URL when building URLs for change set pages and other pages. (optional, default uses server-url)
Examples:
scm: - tfs: server-url: "tfs.company.com" project-path: "$/myproject" login: "mydomain\\jane" use-update: false local-path: "../foo/" workspace: "Hudson-${JOB_NAME}" web-access: - web-url: "http://TFSMachine:8080" scm: - tfs: server-url: "tfs.company.com" project-path: "$/myproject" login: "jane@mydomain" use-update: false local-path: "../foo/" workspace: "Hudson-${JOB_NAME}" web-access: scm: - tfs: server-url: "tfs.company.com" project-path: "$/myproject" login: "mydomain\\jane" use-update: false local-path: "../foo/" workspace: "Hudson-${JOB_NAME}"
- workspace
- Specifies the cloned workspace for this job to use as a SCM source. Requires the Jenkins Clone Workspace SCM Plugin. The job the workspace is cloned from must be configured with an clone-workspace publisher
- Parameters
- •
- parent-job (str) -- The name of the parent job to clone the workspace from.
- •
- criteria (str) -- Set the criteria to determine what build of the parent project to use. Can be one of 'Any', 'Not Failed' or 'Successful'. (default: Any)
Example:
scm: - workspace: parent-job: my-upstream-job criteria: Any
Triggers¶
Triggers define what causes a Jenkins job to start building.- Component: triggers
- Macro
- trigger
- Entry Point
- jenkins_jobs.triggers
Example:
job: name: test_job triggers: - timed: '@daily'
- build-result
- Configure jobB to monitor jobA build result. A build is scheduled if there is a new build result that matches your criteria (unstable, failure, ...). Requires the Jenkins BuildResultTrigger Plugin.
- Parameters
- •
- groups (list) -- List groups of jobs and results to monitor for
- •
- jobs (list) -- The jobs to monitor (required)
- •
- results (list) -- Build results to monitor for (default success)
- •
- combine (bool) -- Combine all job information. A build will be scheduled only if all conditions are met (default false)
- •
- cron (str) -- The cron syntax with which to poll the jobs for the supplied result (default '')
Example:
triggers: - build-result: combine: true cron: '* * * * *' groups: - jobs: - foo - example results: - unstable - jobs: - foo2 results: - not-built - aborted
- gerrit
- Trigger on a Gerrit event. Requires the Jenkins Gerrit Trigger Plugin version >= 2.6.0.
- Parameters
- •
- trigger-on-patchset-uploaded-event (bool) -- Trigger on patchset upload
- •
- trigger-on-change-abandoned-event (bool) -- Trigger on change abandoned. Requires Gerrit Trigger Plugin version >= 2.8.0
- •
- trigger-on-change-merged-event (bool) -- Trigger on change merged
- •
- trigger-on-change-restored-event (bool) -- Trigger on change restored. Requires Gerrit Trigger Plugin version >= 2.8.0
- •
- trigger-on-comment-added-event (bool) -- Trigger on comment added
- •
- trigger-on-draft-published-event (bool) -- Trigger on draft published event
- •
- trigger-on-ref-updated-event (bool) -- Trigger on ref-updated
- •
- trigger-approval-category (str) -- Approval category for comment added
- •
- trigger-approval-value (int) -- Approval value for comment added
- •
- override-votes (bool) -- Override default vote values
- •
- gerrit-build-successful-verified-value (int) -- Successful ''Verified'' value
- •
- gerrit-build-failed-verified-value (int) -- Failed ''Verified'' value
- •
- gerrit-build-successful-codereview-value (int) -- Successful ''CodeReview'' value
- •
- gerrit-build-failed-codereview-value (int) -- Failed ''CodeReview'' value
- •
- failure-message (str) -- Message to leave on failure (default '')
- •
- successful-message (str) -- Message to leave on success (default '')
- •
- unstable-message (str) -- Message to leave when unstable (default '')
- •
- projects (list) -- list of projects to match
- Project
- •
- project-compare-type (str) -- ''PLAIN'', ''ANT'' or ''REG_EXP''
- •
- project-pattern (str) -- Project name pattern to match
- •
- branch-compare-type (str) -- ''PLAIN'', ''ANT'' or ''REG_EXP'' (not used if branches list is specified)
- •
- branch-pattern (str) -- Branch name pattern to match
- (not used if branches list is specified)
- •
- branches (list) -- List of branches to match (optional)
- Branch
- •
- branch-compare-type (str) -- ''PLAIN'', ''ANT'' or ''REG_EXP'' (optional) (default ''PLAIN'')
- •
- branch-pattern (str) -- Branch name pattern to match
- •
- file-paths (list) -- List of file paths to match (optional)
- File Path
- •
- compare-type (str) -- ''PLAIN'', ''ANT'' or ''REG_EXP'' (optional) (default ''PLAIN'')
- •
- pattern (str) -- File path pattern to match
- •
- topics (list) -- List of topics to match (optional)
- File Path
- •
- compare-type (str) -- ''PLAIN'', ''ANT'' or ''REG_EXP'' (optional) (default ''PLAIN'')
- •
- pattern (str) -- Topic name pattern to match
- •
- skip-vote (dict) -- map of build outcomes for which Jenkins must skip vote. Requires Gerrit Trigger Plugin version >= 2.7.0
- Outcome
- •
- successful (bool)
- •
- failed (bool)
- •
- unstable (bool)
- •
- notbuilt (bool)
- •
- silent (bool) -- When silent mode is on there will be no communication back to Gerrit, i.e. no build started/failed/successful approve messages etc. If other non-silent jobs are triggered by the same Gerrit event as this job, the result of this job's build will not be counted in the end result of the other jobs. (default false)
- •
- escape-quotes (bool) -- escape quotes in the values of Gerrit change parameters (default true)
- •
- no-name-and-email (bool) -- Do not pass compound 'name and email' parameters (default false)
- •
- dynamic-trigger-enabled (bool) -- Enable/disable the dynamic trigger (default false)
- •
- dynamic-trigger-url (str) -- if you specify this option, the Gerrit trigger configuration will be fetched from there on a regular interval
- •
- trigger-for-unreviewed-patches (bool) -- trigger patchset-created events for changes that were uploaded while connection to Gerrit was down (default false). Requires Gerrit Trigger Plugin version >= 2.11.0
- •
- custom-url (str) -- Custom URL for a message sent to Gerrit. Build details URL will be used if empty. (default '')
- •
- server-name (str) -- Name of the server to trigger on, or ''__ANY__'' to trigger on any configured Gerrit server (default '__ANY__'). Requires Gerrit Trigger Plugin version >= 2.11.0
You may select one or more Gerrit events upon which to trigger. You must also supply at least one project and branch, optionally more. If you select the comment-added trigger, you should also indicate which approval category and value you want to trigger the job. Until version 0.4.0 of Jenkins Job Builder, camelCase keys were used to configure Gerrit Trigger Plugin, instead of hyphenated-keys. While still supported, camedCase keys are deprecated and should not be used. Example:
triggers: - gerrit: trigger-on-comment-added-event: true trigger-approval-category: 'APRV' trigger-approval-value: 1 projects: - project-compare-type: 'PLAIN' project-pattern: 'test-project' branches: - branch-compare-type: 'PLAIN' branch-pattern: 'master' - branch-compare-type: 'PLAIN' branch-pattern: 'stable' file-paths: - compare-type: ANT pattern: subdirectory/** topics: - compare-type: ANT pattern: refactor-xy** skip-vote: successful: true failed: true unstable: true notbuilt: true silent: false escape-quotes: false no-name-and-email: false dynamic-trigger-enabled: true dynamic-trigger-url: http://myhost/mytrigger trigger-for-unreviewed-patches: true server-name: my-server
- github
- Trigger a job when github repository is pushed to. Requires the Jenkins GitHub Plugin. Example:
triggers: - github
- github-pull-request
- Build pull requests in github and report results. Requires the Jenkins GitHub Pull Request Builder Plugin.
- Parameters
- •
- admin-list (list) -- the users with admin rights (optional)
- •
- white-list (list) -- users whose pull requests build (optional)
- •
- org-list (list) -- orgs whose users should be white listed (optional)
- •
- cron (string) -- cron syntax of when to run (optional)
- •
- trigger-phrase (string) -- when filled, commenting this phrase in the pull request will trigger a build (optional)
- •
- only-trigger-phrase (bool) -- only commenting the trigger phrase in the pull request will trigger a build (default false)
- •
- github-hooks (bool) -- use github hook (default false)
- •
- permit-all (bool) -- build every pull request automatically without asking (default false)
- •
- auto-close-on-fail (bool) -- close failed pull request automatically (default false)
Example:
triggers: - github-pull-request: admin-list: - user1 - user2 white-list: - user3 - user4 org-list: - org1 - org2 cron: '* * * * *' trigger-phrase: 'retest this please' only-trigger-phrase: true github-hooks: true permit-all: false auto-close-on-fail: false
- gitlab-merge-request
- Build merge requests in gitlab and report results. Requires the Jenkins Gitlab MergeRequest Builder Plugin.
- Parameters
- •
- cron (string) -- cron syntax of when to run (required)
- •
- project-path (string) -- gitlab-relative path to project (required)
Example:
triggers: - gitlab-merge-request: cron: '* * * * *' project-path: 'test/project'
- pollscm
- Poll the SCM to determine if there has been a change.
- Parameter
- the polling interval (cron syntax)
Example:
triggers: - pollscm: "\*/15 * * * \*"
- pollurl
- Trigger when the HTTP response from a URL changes. Requires the Jenkins URLTrigger Plugin.
- Parameters
- •
- cron (string) -- cron syntax of when to run (default '')
- •
- polling-node (string) -- Restrict where the polling should run. (optional)
- •
- urls (list) -- List of URLs to monitor
- URL
- •
- url (str) -- URL to monitor for changes (required)
- •
- proxy (bool) -- Activate the Jenkins proxy (default false)
- •
- timeout (int) -- Connect/read timeout in seconds (default 300)
- •
- username (string) -- User name for basic authentication (optional)
- •
- password (string) -- Password for basic authentication (optional)
- •
- check-status (int) -- Check for a specific HTTP status code (optional)
- •
- check-etag (bool) -- Check the HTTP ETag for changes (default false)
- •
- check-date (bool) -- Check the last modification date of the URL (default false)
- •
- check-content (list) -- List of content type changes to monitor
- Content Type
- •
- simple (bool) -- Trigger on any change to the content of the URL (default false)
- •
- json (list) -- Trigger on any change to the listed JSON paths
- •
- text (list) -- Trigger on any change to the listed regular expressions
- •
- xml (list) -- Trigger on any change to the listed XPath expressions
Example:
triggers: - pollurl: cron: '* * * * *' polling-node: 'label expression' urls: - url: 'http://example.com/url1' proxy: false timeout: 442 username: username password: sekr3t check-status: 202 check-etag: false check-date: true check-content: - simple: true - json: - '$..author' - '$.store..price' - url: 'http://example.com/url2' proxy: true check-etag: true check-content: - simple: false - xml: - '//author' - '/store//price' - text: - '\d+'
- reverse
- This trigger can be configured in the UI using the checkbox with the following text: 'Build after other projects are built'. Set up a trigger so that when some other projects finish building, a new build is scheduled for this project. This is convenient for running an extensive test after a build is complete, for example. This configuration complements the "Build other projects" section in the "Post-build Actions" of an upstream project, but is preferable when you want to configure the downstream project.
- Parameters
- •
- jobs (str) -- List (comma separated) of jobs to watch.
- •
- result (str) -- Build results to monitor for between the following options: success, unstable and failure. (default 'success').
Example:
triggers: - reverse: jobs: 'Fantastic-job' result: 'failure'
- script
- Triggers the job using shell or batch script. Requires the Jenkins ScriptTrigger Plugin.
- Parameters
- •
- label (str) -- Restrict where the polling should run. (default '')
- •
- script (str) -- A shell or batch script. (default '')
- •
- cron (str) -- cron syntax of when to run (default '')
- •
- enable-concurrent (bool) -- Enables triggering concurrent builds. (default false)
- •
- exit-code (int) -- If the exit code of the script execution returns this expected exit code, a build is scheduled. (default 0)
Example:
triggers: - script: script: 'exit 0' cron: 'H/15 * * * *' enable-concurrent: False label: master exit-code: 0
- timed
- Trigger builds at certain times.
- Parameter
- when to run the job (cron syntax)
Example:
triggers: - timed: "@midnight"
Wrappers¶
Wrappers can alter the way the build is run as well as the build output.- Component: wrappers
- Macro
- wrapper
- Entry Point
- jenkins_jobs.wrappers
- ansicolor
- Translate ANSI color codes to HTML in the console log. Requires the Jenkins Ansi Color Plugin.
- Parameters
- colormap (string) -- (optional) color mapping to use
Examples:
wrappers: - ansicolor # Explicitly setting the colormap wrappers: - ansicolor: colormap: vga
- build-name
- Set the name of the build Requires the Jenkins Build Name Setter Plugin.
- Parameters
- name (str) -- Name for the build. Typically you would use a variable from Jenkins in the name. The syntax would be ${FOO} for the FOO variable.
Example:
wrappers: - build-name: name: Build-${FOO}
- build-user-vars
- Set environment variables to the value of the user that started the build. Requires the Jenkins Build User Vars Plugin. Example:
wrappers: - build-user-vars
- ci-skip
- Skip making a build for certain push. Just add [ci skip] into your commit's message to let Jenkins know, that you do not want to perform build for the next push. Requires the Jenkins Ci Skip Plugin. Example:
wrappers: - ci-skip
- copy-to-slave
- Copy files to slave before build Requires the Jenkins Copy To Slave Plugin.
- Parameters
- •
- includes (list) -- list of file patterns to copy
- •
- excludes (list) -- list of file patterns to exclude
- •
- flatten (bool) -- flatten directory structure
- •
- relative-to (str) -- base location of includes/excludes, must be userContent ($JENKINS_HOME/userContent) home ($JENKINS_HOME) or workspace
- •
- include-ant-excludes (bool) -- exclude ant's default excludes
Example:
wrappers: - copy-to-slave: includes: - file1 - file2*.txt excludes: - file2bad.txt
- delivery-pipeline
- If enabled the job will create a version based on the template. The version will be set to the environment variable PIPELINE_VERSION and will also be set in the downstream jobs. Requires the Jenkins Delivery Pipeline Plugin.
- Parameters
- •
- version-template (str) -- Template for generated version e.g 1.0.${BUILD_NUMBER} (default: '')
- •
- set-display-name (bool) -- Set the generated version as the display name for the build (default: false)
Example:
wrappers: - delivery-pipeline: version-template: 1.0.0-${BUILD_NUMBER} set-display-name: true
- env-file
- Add or override environment variables to the whole build process Requires the Jenkins Environment File Plugin.
- Parameters
- properties-file (str) -- path to the properties file (default '')
Example:
wrappers: - env-file: properties-file: ${WORKSPACE}/foo
- env-script
- Add or override environment variables to the whole build process. Requires the Jenkins Environment Script Plugin.
- Parameters
- •
- script-content -- The script to run (default: '')
- •
- only-run-on-parent -- Only applicable for Matrix Jobs. If true, run only on the matrix parent job (default: false)
Example:
wrappers: - env-script: script-content: 'echo foo=bar' only-run-on-parent: true
- exclusion
- Add a resource to use for critical sections to establish a mutex on. If another job specifies the same resource, the second job will wait for the blocked resource to become available. Requires the Jenkins Exclusion Plugin.
- Parameters
- resources (list) -- List of resources to add for exclusion
Example:
wrappers: - exclusion: resources: - myresource1 - myresource2
- inject
- Add or override environment variables to the whole build process Requires the Jenkins EnvInject Plugin.
- Parameters
- •
- properties-file (str) -- path to the properties file (default '')
- •
- properties-content (str) -- key value pair of properties (default '')
- •
- script-file (str) -- path to the script file (default '')
- •
- script-content (str) -- contents of a script (default '')
Example:
wrappers: - inject: properties-file: /usr/local/foo properties-content: PATH=/foo/bar script-file: /usr/local/foo.sh script-content: echo $PATH
- inject-ownership-variables
- Inject ownership variables to the build as environment variables. Requires the Jenkins EnvInject Plugin and Jenkins Ownership plugin <https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin>
- Parameters
- •
- job-variables (bool) -- inject job ownership variables to the job (default false)
- •
- node-variables (bool) -- inject node ownership variables to the job (default false)
Example:
wrappers: - inject-ownership-variables: job-variables: true node-variables: true
- inject-passwords
- Inject passwords to the build as environment variables. Requires the Jenkins EnvInject Plugin.
- Parameters
- •
- global (bool) -- inject global passwords to the job
- •
- job-passwords (list) -- key value pair of job passwords
- Parameter
- •
- name (str) Name of password
- •
- password (str) Encrypted password
Example:
wrappers: - inject-passwords: global: true job-passwords: - name: ADMIN password: 0v8ZCNaHwq1hcx+sHwRLdg9424uBh4Pin0zO4sBIb+U=
- jclouds
- Uses JClouds to provide slave launching on most of the currently usable Cloud infrastructures. Requires the Jenkins JClouds Plugin.
- Parameters
- •
- single-use (bool) -- Whether or not to terminate the slave after use (default: False).
- •
- instances (list) -- The name of the jclouds template to create an instance from, and its parameters.
- •
- cloud-name (str) -- The name of the jclouds profile containing the specified template.
- •
- count (int) -- How many instances to create (default: 1).
- •
- stop-on-terminate (bool) -- Whether or not to suspend instead of terminate the instance (default: False).
Example:
wrappers: - jclouds: single-use: True instances: - jenkins-dev-slave: cloud-name: mycloud1 count: 1 stop-on-terminate: True - jenkins-test-slave: cloud-name: mycloud2 count: 2 stop-on-terminate: False
- locks
- Control parallel execution of jobs. Requires the Jenkins Locks and Latches Plugin.
- Arg
- list of locks to use
Example:
wrappers: - locks: - FOO - FOO2
- logfilesize
- Abort the build if its logfile becomes too big. Requires the Jenkins Logfilesizechecker Plugin.
- Parameters
- •
- set-own (bool) -- Use job specific maximum log size instead of global config value (default false).
- •
- fail (bool) -- Make builds aborted by this wrapper be marked as "failed" (default false).
- •
- size (int) -- Abort the build if logfile size is bigger than this value (in MiB, default 128). Only applies if set-own is true.
Minimum config example:
wrappers: - logfilesize
Full config example:
wrappers: - logfilesize: set-own: true size: 1024 fail: true
- logstash build wrapper
- Dump the Jenkins console output to Logstash Requires the Jenkins logstash plugin.
- Parameters
- •
- use-redis -- Boolean to use Redis. (default: true)
- •
- redis -- Redis config params
- Parameter
- •
- host (str) Redis hostname (default 'localhost')
- Parameter
- •
- port (int) Redis port number (default 6397)
- Parameter
- •
- database-number (int) Redis database number (default 0)
- Parameter
- •
- database-password (str) Redis database password (default '')
- Parameter
- •
- data-type (str) Redis database type (default 'list')
- Parameter
- •
- key (str) Redis key (default 'logstash')
Example:
wrappers: - logstash: use-redis: True redis: host: 'localhost' port: 6379 database-number: 0 database-password: 'password' data-type: 'list' key: 'logstash'
- mask-passwords
- Hide passwords in the console log. Requires the Jenkins Mask Passwords Plugin. Example:
wrappers: - mask-passwords
- matrix-tie-parent
- Tie parent to a node. Requires the Jenkins Matrix Tie Parent Plugin. Note that from Jenkins version 1.532 this plugin's functionality is available under the "advanced" option of the matrix project configuration.
- Parameters
- node (str) -- Name of the node.
Example:
project-type: matrix wrappers: - matrix-tie-parent: node: Unix
- pathignore
- This plugin allows SCM-triggered jobs to ignore build requests if only certain paths have changed. Requires the Jenkins Pathignore Plugin.
- Parameters
- ignored (str) -- A set of patterns to define ignored changes
Example:
wrappers: - pathignore: ignored: "docs, tests"
- port-allocator
- Assign unique TCP port numbers Requires the Jenkins Port Allocator Plugin.
- Parameters
- name (str) -- Variable name of the port or a specific port number
Example:
wrappers: - port-allocator: name: SERVER_PORT
- pre-scm-buildstep
- Execute a Build Step before running the SCM Requires the Jenkins pre-scm-buildstep.
- Parameters
- buildsteps (list) -- List of build steps to execute
- Buildstep
- Any acceptable builder, as seen in the example
Example:
wrappers: - pre-scm-buildstep: - shell: | #!/bin/bash echo "Doing somethiung cool" - shell: | #!/bin/zsh echo "Doing somethin cool with zsh" - ant: "target1 target2" ant-name: "Standard Ant" - inject: properties-file: example.prop properties-content: EXAMPLE=foo-bar
- rbenv
- Set the rbenv implementation. Requires the Jenkins rbenv plugin. All parameters are optional.
- Parameters
- •
- ruby-version (str) -- Version of Ruby to use (default: 1.9.3-p484)
- •
- ignore-local-version (bool) -- If true, ignore local Ruby version (defined in the ".ruby-version" file in workspace) even if it has been defined (default: false)
- •
- preinstall-gem-list (str) -- List of gems to install (default: 'bundler,rake')
- •
- rbenv-root (str) -- RBENV_ROOT (default: $HOME/.rbenv)
- •
- rbenv-repo (str) -- Which repo to clone rbenv from (default: https://github.com/sstephenson/rbenv.git)
- •
- rbenv-branch (str) -- Which branch to clone rbenv from (default: master)
- •
- ruby-build-repo (str) -- Which repo to clone ruby-build from (default: https://github.com/sstephenson/ruby-build.git)
- •
- ruby-build-branch (str) -- Which branch to clone ruby-build from (default: master)
Example:
wrappers: - rbenv: ruby-version: 2.0.0-p353 ignore-local-version: false preinstall-gem-list: "bundler,rake" rbenv-root: "$HOME/.rbenv" rbenv-repo: "https://github.com/sstephenson/rbenv.git" rbenv-branch: "master" ruby-build-repo: "https://github.com/sstephenson/ruby-build.git" ruby-build-branch: "master"
- release
- Add release build configuration Requires the Jenkins Release Plugin.
- Parameters
- •
- keep-forever (bool) -- Keep build forever (default true)
- •
- override-build-parameters (bool) -- Enable build-parameter override
- •
- version-template (string) -- Release version template
- •
- parameters (list) -- Release parameters (see the Parameters module)
- •
- pre-build (list) -- Pre-build steps (see the Builders module)
- •
- post-build (list) -- Post-build steps (see Builders)
- •
- post-success (list) -- Post successful-build steps (see Builders)
- •
- post-failed (list) -- Post failed-build steps (see Builders)
Example:
wrappers: - release: keep-forever: false parameters: - string: name: RELEASE_BRANCH default: '' description: Git branch to release from. post-success: - shell: | #!/bin/bash copy_build_artefacts.sh
- rvm-env
- Set the RVM implementation Requires the Jenkins Rvm Plugin.
- Parameters
- implementation (str) -- Type of implementation. Syntax is RUBY[@GEMSET], such as '1.9.3' or 'jruby@foo'.
Example:
wrappers: - rvm-env: implementation: 1.9.3
- sauce-ondemand
- Allows you to integrate Sauce OnDemand with Jenkins. You can automate the setup and tear down of Sauce Connect and integrate the Sauce OnDemand results videos per test. Requires the Jenkins Sauce OnDemand Plugin.
- Parameters
- •
- enable-sauce-connect (bool) -- launches a SSH tunnel from their cloud to your private network (default false)
- •
- sauce-host (str) -- The name of the selenium host to be used. For tests run using Sauce Connect, this should be localhost. ondemand.saucelabs.com can also be used to conenct directly to Sauce OnDemand, The value of the host will be stored in the SAUCE_ONDEMAND_HOST environment variable. (default '')
- •
- sauce-port (str) -- The name of the Selenium Port to be used. For tests run using Sauce Connect, this should be 4445. If using ondemand.saucelabs.com for the Selenium Host, then use 4444. The value of the port will be stored in the SAUCE_ONDEMAND_PORT environment variable. (default '')
- •
- override-username (str) -- If set then api-access-key must be set. Overrides the username from the global config. (default '')
- •
- override-api-access-key (str) -- If set then username must be set. Overrides the api-access-key set in the global config. (default '')
- •
- starting-url (str) -- The value set here will be stored in the SELENIUM_STARTING_ULR environment variable. Only used when type is selenium. (default '')
- •
- type (str) -- Type of test to run (default selenium)
- type values
- •
- selenium
- •
- webdriver
- •
- platforms (list) -- The platforms to run the tests on. Platforms supported are dynamically retrieved from sauce labs. The format of the values has only the first letter capitalized, no spaces, underscore between os and version, underscore in internet_explorer, everything else is run together. If there are not multiple version of the browser then just the first version number is used. Examples: Mac_10.8iphone5.1 or Windows_2003firefox10 or Windows_2012internet_explorer10 (default '')
- •
- launch-sauce-connect-on-slave (bool) -- Whether to launch sauce connect on the slave. (default false)
- •
- https-protocol (str) -- The https protocol to use (default '')
- •
- sauce-connect-options (str) -- Options to pass to sauce connect (default '')
Example:
wrappers: - sauce-ondemand: enable-sauce-connect: true sauce-host: foo sauce-port: 8080 override-username: foo override-api-access-key: 123lkj123kh123l;k12323 type: webdriver platforms: - Linuxandroid4 - Linuxfirefox10 - Linuxfirefox11 launch-sauce-connect-on-slave: true
- ssh-agent-credentials
- Sets up the user for the ssh agent plugin for jenkins. Requires the Jenkins SSH-Agent Plugin.
- Parameters
- user (str) -- The user id of the jenkins user credentials (required)
Example:
wrappers: - ssh-agent-credentials: user: '49d20745-9889-4c02-b286-fc6fb89c36bd'
- timeout
- Abort the build if it runs too long. Requires the Jenkins Build Timeout Plugin.
- Parameters
- •
- fail (bool) -- Mark the build as failed (default false)
- •
- write-description (bool) -- Write a message in the description (default false)
- •
- timeout (int) -- Abort the build after this number of minutes (default 3)
- •
- timeout-var (str) -- Export an environment variable to reference the timeout value (optional)
- •
- type (str) -- Timeout type to use (default absolute)
- •
- elastic-percentage (int) -- Percentage of the three most recent builds where to declare a timeout (default 0)
- •
- elastic-default-timeout (int) -- Timeout to use if there were no previous builds (default 3)
Example:
wrappers: - timeout: timeout: 90 timeout-var: 'BUILD_TIMEOUT' fail: true type: absolute
wrappers: - timeout: fail: false type: likely-stuck
wrappers: - timeout: timeout-var: 'BUILD_TIMEOUT' fail: true elastic-percentage: 150 elastic-default-timeout: 90 type: elastic
- timestamps
- Add timestamps to the console log. Requires the Jenkins Timestamper Plugin. Example:
wrappers: - timestamps
- workspace-cleanup (pre-build)
- Requires the Jenkins Workspace Cleanup Plugin. The post-build workspace-cleanup is available as a publisher.
- Parameters
- •
- include (list) -- list of files to be included
- •
- exclude (list) -- list of files to be excluded
- •
- dirmatch (bool) -- Apply pattern to directories too
Example:
wrappers: - workspace-cleanup: include: - "*.zip"
Zuul¶
The Zuul module adds triggers that configure jobs for use with Zuul. It essentially adds the jobs parameters expected by Zuul. With Zuul version 2.0 and later, this is optional. The jobs are triggered via the Jenkins Gearman plugin which passes the parameters internally. You might still want to explicitly define parameters to retain the possibility of triggering jobs manually via the Jenkins web interface (build with parameters). To change the Zuul notification URL, set a global default:- defaults: name: global zuul-url: http://127.0.0.1:8001/jenkins_endpoint
The above URL is the default.
- zuul
- Configure this job to be triggered by Zuul. Adds parameters describing the change triggering the build such as the branch name, change number and patchset. See parameters expected by Zuul. Example:
triggers: - zuul
- zuul-post
- Configure this post-merge job to be triggered by Zuul. Adds parameters describing the reference update triggering the build, which are the previous and next revisions in full (40 hexadecimal sha1) and short form. See parameters expected by Zuul. Example:
triggers: - zuul-post
Module Execution¶
The jenkins job builder modules are executed in sequence.- Generally the sequence is:
- 1.
- parameters/properties
- 2.
- scm
- 3.
- triggers
- 4.
- wrappers
- 5.
- prebuilders (maven only, configured like builders)
- 6.
- builders (maven, freestyle, matrix, etc..)
- 7.
- postbuilders (maven only, configured like builders)
- 8.
- publishers/reporters/notifications
EXTENDING¶
Jenkins Job Builder is quite modular. It is easy to add new attributes to existing components, a new module to support a Jenkins plugin, or include locally defined methods to deal with an idiosyncratic build system.The Builder¶
The Builder class manages Jenkins jobs. It's responsible for creating/deleting/updating jobs and can be called from your application. You can pass it a filename or an open file-like object that represents your YAML configuration. See the jenkins_jobs/builder.py file for more details.XML Processing¶
Most of the work of building XML from the YAML configuration file is handled by individual functions that implement a single characteristic. For example, see the jenkins_jobs/modules/builders.py file for the Python module that implements the standard Jenkins builders. The shell function at the top of the file implements the standard Execute a shell build step. All of the YAML to XML functions in Jenkins Job Builder have the same signature:- component(parser, xml_parent, data)
- Parameters
- •
- parser (YAMLParser) -- the jenkins jobs YAML parser
- •
- xml_parent (Element) -- this attribute's parent XML element
- •
- data (dict) -- the YAML data structure for this attribute and below
The function is expected to examine the YAML data structure and create new XML nodes and attach them to the xml_parent element. This general pattern is applied throughout the included modules.
Modules¶
Nearly all of Jenkins Job Builder is implemented in modules. The main program has no concept of builders, publishers, properties, or any other aspects of job definition. Each of those building blocks is defined in a module, and due to the use of setuptools entry points, most modules are easily extensible with new components. To add a new module, define a class that inherits from jenkins_jobs.modules.base.Base, and add it to the jenkins_jobs.modules entry point in your setup.py.- class jenkins_jobs.modules.base.Base(registry)
- A base class for a Jenkins Job Builder Module. The module is initialized before any YAML is parsed.
- Parameters
- registry (ModuleRegistry) -- the global module registry.
- component_list_type = None
- The component list type will be used to look up possible implementations of the component type via entry points (entry points provide a list of components, so it should be plural). Set both component_type and component_list_type to None if module doesn't have components.
- component_type = None
- The component type for components of this module. This will be used to look for macros (they are defined singularly, and should not be plural). Set both component_type and component_list_type to None if module doesn't have components.
- gen_xml(parser, xml_parent, data)
- Update the XML element tree based on YAML data. Override this method to add elements to the XML output. Create new Element objects and add them to the xml_parent. The YAML data structure must not be modified.
- Parameters
- •
- parser (YAMLParser) -- the global YAML Parser
- •
- xml_parent (Element) -- the parent XML element
- •
- data (dict) -- the YAML data structure
- handle_data(parser)
- This method is called before any XML is generated. By overriding this method, the module may manipulate the YAML data structure on the parser however it likes before any XML is generated. If it has changed the data structure at all, it must return True, otherwise, it must return False.
- Parameters
- parser (YAMLParser) -- the global YAML Parser
- Return type
- boolean
- sequence = 10
- The sequence number for the module. Modules are invoked in the order of their sequence number in order to produce consistently ordered XML output.
Components¶
Most of the standard modules supply a number of components, and it's easy to provide your own components for use by those modules. For instance, the Builders module provides several builders, such as the shell builder as well as the trigger_builds builder. If you wanted to add a new builder, all you need to do is write a function that conforms to the Component Interface, and then add that function to the appropriate entry point (via a setup.py file).Module Registry¶
All modules and their associated components are registered in the module registry. It can be accessed either from modules via the registry field, or via the parser parameter of components.- class jenkins_jobs.builder.ModuleRegistry(config)
- dispatch(component_type, parser, xml_parent, component, template_data={})
- This is a method that you can call from your implementation of Base.gen_xml or component. It allows modules to define a type of component, and benefit from extensibility via Python entry points and Jenkins Job Builder Macros.
- Parameters
- •
- component_type (string) -- the name of the component (e.g., builder)
- •
- parser (YAMLParser) -- the global YAML Parser
- •
- xml_parent (Element) -- the parent XML element
- •
- template_data (dict) -- values that should be interpolated into the component definition
See jenkins_jobs.modules.base.Base for how to register components of a module. See the Publishers module for a simple example of how to use this method.
- •
- genindex
- •
- modindex
- •
- search
AUTHOR¶
Jenkins Job Builder MaintainersCOPYRIGHT¶
2012, Jenkins Job Builder MaintainersDecember 22, 2014 | 0.9.0 |