Multibranch Pipeline Project

The Multibranch Pipeline project module handles creating Jenkins workflow projects. You may specify multibranch in the project-type attribute of the Job definition.

Multibranch Pipeline implementantion in JJB is marked as experimental which means that there is no guarantee that its behavior (or configuration) will not change, even between minor releases.

Plugins required:
Job Parameters:
  • scm (list): The SCM definition.

    • bitbucket (dict): Refer to ~bitbucket_scm for documentation.
    • gerrit (dict): Refer to ~gerrit_scm for documentation.
    • git (dict): Refer to ~git_scm for documentation.
    • github (dict): Refer to ~github_scm for documentation.
  • periodic-folder-trigger (str): How often to scan for new branches or pull/change requests. Valid values: 1m, 2m, 5m, 10m, 15m, 20m, 25m, 30m, 1h, 2h, 4h, 8h, 12h, 1d, 2d, 1w, 2w, 4w. (default none)

  • prune-dead-branches (bool): If dead branches upon check should result in their job being dropped. (default true)

  • number-to-keep (int): How many builds should be kept. (default ‘-1, all’)

  • days-to-keep (int): For how many days should a build be kept. (default ‘-1, forever’)

Job examples:

name: 'demo-multibranch-defaults'
project-type: multibranch-defaults
scm:
    - github:
        repo: 'foo'
        repo-owner: 'johndoe'
        credentials-id: 'secret'
name: 'demo-multibranch-multi-scm-full'
description: 'Workflow demo'

project-type: multibranch

periodic-folder-trigger: 1d
prune-dead-branches: True
number-to-keep: '10'
days-to-keep: '10'
scm:
    - bitbucket:
        repo-owner: 'SANDBOX'
        repo: 'test'
        credentials-id: 'secret'
    - git:
        url: 'https://example.com/jonhndoe/keep-frontend.git'
        credentials-id: 'secret'
    - github:
        repo: 'foo'
        repo-owner: 'johndoe'
        credentials-id: 'secret'
class project_multibranch.WorkflowMultiBranch(registry)
class project_multibranch.WorkflowMultiBranchDefaults(registry)
project_multibranch.bitbucket_scm(xml_parent, data)

Configure BitBucket scm

Requires the Bitbucket Branch Source Plugin.

Parameters:
  • credentials-id (str) – The credential to use to scan BitBucket. (required)
  • repo-owner (str) – Specify the name of the Bitbucket Team or Bitbucket User Account. (required)
  • repo (str) – The BitBucket repo. (required)
  • discover-tags (bool) – Discovers tags on the repository. (default false)

Minimal Example:

name: 'demo-multibranch-bitbucket-min'
project-type: multibranch
scm:
    - bitbucket:
        repo-owner: 'SANDBOX'
        repo: 'test'

Full Example:

name: 'demo-multibranch-bitbucket-min'
project-type: multibranch
scm:
    - bitbucket:
        credentials-id: 'secret'
        repo-owner: 'SANDBOX'
        repo: 'test'
        discover-tags: true
project_multibranch.gerrit_scm(xml_parent, data)

Configure Gerrit SCM

Requires the Gerrit Code Review Plugin.

Parameters:
  • url (str) – The git url. (required)
  • credentials-id (str) – The credential to use to connect to the GIT URL.
  • ignore-on-push-notifications (bool) – If a job should not trigger upon push notifications. (default false)
  • refspecs (list(str)) – Which refspecs to look for. (default ['+refs/changes/*:refs/remotes/@{remote}/*', '+refs/heads/*:refs/remotes/@{remote}/*'])
  • includes (str) – Comma-separated list of branches to be included. (default ‘*’)
  • excludes (str) – Comma-separated list of branches to be excluded. (default ‘’)

Minimal Example:

name: 'demo-multibranch-gerrit-min'
project-type: multibranch
scm:
    - gerrit:
        url: 'https://review.gerrithub.io/johndoe/foo'

Full Example:

name: 'demo-multibranch-gerrit-min'
project-type: multibranch
scm:
    - gerrit:
        url: 'https://review.gerrithub.io/johndoe/foo'
        credentials-id: secret
        ignore-on-push-notifications: true
        refspecs: 'refs/heads/*'
project_multibranch.git_scm(xml_parent, data)

Configure Git SCM

Requires the Git Plugin.

Parameters:
  • url (str) – The git repo url. (required)
  • credentials-id (str) – The credential to use to connect to the GIT repo. (default ‘’)
  • discover-branches (bool) – Discovers branches on the repository. (default true)
  • discover-tags (bool) – Discovers tags on the repository. (default false)
  • ignore-on-push-notifications (bool) – If a job should not trigger upon push notifications. (default false)

Minimal Example:

name: 'demo-multibranch-git-min'
project-type: multibranch
scm:
    - git:
        url: 'https://example.com/jonhndoe/keep-frontend.git'

Full Example:

name: 'demo-multibranch-git-min'
project-type: multibranch
scm:
    - git:
        url: 'https://example.com/jonhndoe/keep-frontend.git'
        credentials-id: secret
        discover-branches: false
        ignore-on-push-notifications: true
        discover-tags: true
project_multibranch.github_scm(xml_parent, data)

Configure GitHub SCM

Requires the GitHub Branch Source Plugin.

Parameters:
  • api-uri (str) – The GitHub API uri for hosted / on-site GitHub. Must first be configured in Global Configuration. (default GitHub)
  • credentials-id (str) – Credentials used to scan branches and pull requests, check out sources and mark commit statuses. (optional)
  • repo-owner (str) – Specify the name of the GitHub Organization or GitHub User Account. (required)
  • repo (str) – The GitHub repo. (required)
  • branch-discovery (str) – Discovers branches on the repository. Valid options: no-pr, only-pr, all, false. (default ‘no-pr’)
  • discover-pr-forks-strategy (str) – Fork strategy. Valid options: merge-current, current, both, false. (default ‘merge-current’)
  • discover-pr-forks-trust (str) – Discovers pull requests where the origin repository is a fork of the target repository. Valid options: contributors, everyone, permission or nobody. (default ‘contributors’)
  • discover-pr-origin (str) – Discovers pull requests where the origin repository is the same as the target repository. Valid options: merge-current, current, both. (default ‘merge-current’)
  • discover-tags (bool) – Discovers tags on the repository. (default false)

Minimal Example:

name: 'demo-multibranch-github-min'
project-type: multibranch
scm:
    - github:
        repo: 'foo'
        repo-owner: 'johndoe'

Full Example:

name: scm-github-full
project-type: multibranch
scm:
    - github:
        api-uri: http://example.org/github
        repo: example-repo
        repo-owner: example-owner
        credentials-id: example-credential
        branch-discovery: all
        discover-pr-forks-strategy: both
        discover-pr-forks-trust: everyone
        discover-pr-origin: both
        discover-tags: true