Managing Multibranch Pipeline options in template.yaml

2 minute read

You can manage Multibranch Pipelines in template.yaml files using the multibranch: configuration block.

Each multibranch: configuration block contains the following values:

  • Source control: specifies the source control provider.

  • Orphaned item strategy: specifies the strategy to use for retaining orphaned items.

  • Custom marker file: specifies the custom marker file.

  • Scan repository interval: specifies the scan repository interval.

For more information on Multibranch Pipeline Template syntax, see Multibranch Pipeline Template syntax.

Customizing the Source Control value

The source control value defines the source control provider and credentials.

You can find examples of the supported source control providers at https://github.com/cloudbees/cloudbees-examples/tree/master/pipeline-template-examples/demos.
GitHub.com
GitHub Enterprise
Git
Bitbucket.org
Bitbucket Server
multibranch: branchSource: github: repoOwner: organization.example repository: ${repoName} credentialsId: ${my-team-github-credentials}
multibranch: branchSource: github: apiUri: https://github.example.com/api/v3 repoOwner: organization.example repository: ${repoName} credentialsId: ${my-team-github-credentials}
multibranch: branchSource: git: remote: ${repoUrl} credentialsId: ${my-team-git-credentials}
multibranch: branchSource: bitbucket: serverUrl: https://bitbucket.org repoOwner: organization.example repository: ${repoName} credentialsId: ${my-team-bitbucket-credentials}
multibranch: branchSource: bitbucket: serverUrl: https://bitbucket.example.com repoOwner: organization.example repository: ${repoName} credentialsId: ${my-team-bitbucket-credentials}

Customizing the Orphaned Items Strategy configuration

CloudBees CI includes configuration options to store jobs based on your organization’s retention strategy. By default, jobs are removed as soon as the folder computation determines they are no longer present. However, if your organization requires these items to remain available or you would like to review the build results of a branch after it has been removed, you can configure the orphaned item strategy to store the jobs for however long they’re needed. By default, child multibranch projects inherit the orphaned item strategy of their parent organization folder. If necessary, you can assign a different orphaned item strategy to a child multibranch project than that of the parent organization folder.

Example

name: A Multibranch Template with Orphaned Items type: pipeline-template templateType: MULTIBRANCH parameters: - name: repoUrl type: string displayName: Repo multibranch: branchSource: git: remote: ${repoUrl} orphanedItemStrategy: daysToKeep: 3

Using a custom marker file with templates

You can use a custom marker file with your templates by defining it in the template.yaml file for your template.

The following examples are intended to show how you could use the default manifest files for different types of projects as a custom marker file. However, you may choose to use whichever file and file type that you wish.

Examples

Java (with Maven)
NodeJS/Angular
Python
C++
name: Multibranch with marker file type: pipeline-template templateType: MULTIBRANCH parameters: - name: repoUrl type: string displayName: Repository multibranch: branchSource: git: remote: ${repoUrl} markerFile: pom.xml
name: Multibranch with marker file type: pipeline-template templateType: MULTIBRANCH parameters: - name: repoUrl type: string displayName: Repository multibranch: branchSource: git: remote: ${repoUrl} markerFile: package.json
name: Multibranch with marker file type: pipeline-template templateType: MULTIBRANCH parameters: - name: repoUrl type: string displayName: Repository multibranch: branchSource: git: remote: ${repoUrl} markerFile: MAKEFILE
name: Multibranch with marker file type: pipeline-template templateType: MULTIBRANCH parameters: - name: repoUrl type: string displayName: Repository multibranch: branchSource: git: remote: ${repoUrl} markerFile: package.xml

Configuring the scan repository interval for templates

You can use a template to configure how frequently the pipeline scans for repository updates.

Example

multibranch: branchSource: git: remote: ${repoUrl} scanRepositoryInterval: 2 hours