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
Parameters:ant-name (str) – the name of the ant installation, defaults to ‘default’ (optional)

Example to call two Ant targets:

builders:
  - ant: "target1 target2"
     ant-name: "Standard Ant"

The build file would be whatever the Jenkins Ant Plugin is set to use per default (i.e build.xml in the workspace root).

2) Using named parameters:

Parameters:
  • 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, defaults to ‘default’ (optional)

Example specifying the build file too and several targets:

builders:
  - ant:
     targets: "debug test install"
     buildfile: "build.xml"
     properties:
        builddir: "/tmp/"
        failonerror: true
     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:
      - project: "base-build"
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

Example:

builders:
  - copyartifact:
      project: foo
      filter: *.tar.gz
gradle

Execute gradle tasks. Requires the Jenkins ‘Gradle Plugin. <https://wiki.jenkins-ci.org/display/JENKINS/Gradle+Plugin>`_

Parameters:
  • tasks (str) – List of tasks to execute
  • wrapper (bool) – use gradle wrapper (default false)
  • executable (bool) – make gradlew executable (default false)

Example:

builders:
  - gradle:
      wrapper: true
      executable: true
      tasks: |
             init
             build
             tests
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
shell

Execute a shell command.

Parameter :the shell command to execute

Example:

builders:
  - shell: "make test"
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)
  • block (bool) – whether to wait for the triggered jobs to finish or not (default false)

Example:

builders:
  - trigger-builds:
      - project: "build_started"
        predefined-parameters:
          FOO="bar"
        block: true

Previous topic

General Job Configuration

Next topic

Hipchat

This Page