Pipeline Project

The Pipeline Project module handles creating Jenkins Pipeline projects (formerly known as the Workflow projects). You may specify pipeline in the project-type attribute of the Job definition.

Requires the Jenkins Pipeline Plugin.

In order to write an inline script within a job-template you have to escape the curly braces by doubling them in the DSL: { -> {{ , otherwise it will be interpreted by the python str.format() command.

Job Parameters:
  • sandbox (bool): If the script should run in a sandbox (default false)

  • dsl (str): The DSL content or,

  • pipeline-scm (str): in case “Pipeline as code” feature is used. Then you should specify:

    • scm: single scm component (or a reference) describing the source code repository

    • script-path: path to the Groovy file containing the job’s steps (optional, default: Jenkinsfile)

    • lightweight-checkout (bool): If selected, try to obtain the Pipeline script contents directly from the SCM without performing a full checkout. (optional, default: false)

Note that dsl and pipeline-scm parameters are mutually exclusive.

Inline DSL job example:

- job:
    name: test_job
    project-type: pipeline
    dsl: |
      build job: "job1"
      parallel [
        2a: build job: "job2a",
        2b: node "dummynode" {{
          sh "echo I'm alive!"
        }}
      ]

Inline DSL job template example:

- job-template:
    name: '{name}-unit-tests'
    project-type: pipeline
    dsl: |
        build job: "job1"
        parallel [
          2a: build job: "job2a",
          2b: node "dummynode" {{
            sh "echo {isay}"
          }}
        ]

- job-group:
    name: '{name}-tests'
    jobs:
      - '{name}-unit-tests':
          isay: 'hello'

- project:
    name: project-name
    jobs:
    - '{name}-tests'

“Pipeline as code” example:

- job:
    name: test-job
    project-type: pipeline
    sandbox: true
    pipeline-scm:
      scm:
        - hg:
            url: http://hg.example.org/test_job
            clean: true
      script-path: Jenkinsfile.groovy
      lightweight-checkout: true

“Pipeline as code” example using templates:

- scm:
    name: project-scm
    scm:
      - hg:
         url: http://hg.example.org/project
         clean: true

- job-template:
    name: '{name}-unit-tests'
    project-type: pipeline
    pipeline-scm:
      scm:
        - project-scm
    sandbox: true
    description: 'maintainer: {maintainer}'

- job-template:
    name: '{name}-perf-tests'
    project-type: pipeline
    pipeline-scm:
      scm:
        - project-scm
    sandbox: false
    description: 'maintainer: {maintainer}'

- job-group:
    name: '{name}-tests'
    jobs:
      - '{name}-unit-tests':
          maintainer: dev@example.org
      - '{name}-perf-tests':
          maintainer: qa@example.org

- project:
    name: project-name
    jobs:
    - '{name}-tests'

“Pipeline as nested stage” example :

- job-template:
    name: '{name}-unit-tests'
    project-type: pipeline
    dsl: |
      stage('Build another job') {{
        build(job: "{isay}")
      }}

- job-group:
    name: '{name}-tests'
    jobs:
      - '{name}-unit-tests':
          isay: 'hello'

- project:
    name: project-name
    jobs:
    - '{name}-tests'
class project_pipeline.Pipeline(registry)
sequence = 0

The sequence number for the module. Modules are invoked in the order of their sequence number in order to produce consistently ordered XML output.