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

Example:

job:
  name: test_job

  wrappers:
    - timeout:
        timeout: 90
        fail: true
ansicolor

Translate ANSI color codes to HTML in the console log. Requires the Jenkins Ansi Color Plugin.

Example:

wrappers:
  - ansicolor
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
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
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
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
mask-passwords

Hide passwords in the console log. Requires the Jenkins Mask Passwords Plugin.

Example:

wrappers:
  - mask-passwords
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
release

Add release build configuration Requires the Jenkins Release Plugin.

Parameters:
  • keep-forever (bool) – Keep build forever (default is ‘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
timeout

Abort the build if it runs too long. Requires the Jenkins Build Timeout Plugin.

Parameters:
  • timeout (int) – Abort the build after this number of minutes
  • fail (bool) – Mark the build as failed (default false)

Example:

wrappers:
  - timeout:
      timeout: 90
      fail: true
timestamps

Add timestamps to the console log. Requires the Jenkins Timestamper Plugin.

Example:

wrappers:
  - timestamps
workspace-cleanup (pre-build)

See 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"

Previous topic

Triggers

Next topic

Zuul

This Page