Create a Multi-branch Pipeline¶
Workbench supports the creation of multi-branch pipelines based on code repositories.
Prerequisites¶
- Create a Workspace and Create a User.
- Add the user to the workspace with workspace editor privileges or higher.
- Have a code repository with multiple branches, each containing a Jenkinsfile.
- If using a private repository, you'll need to create credentials beforehand.
Steps¶
-
Click Create Pipeline on the pipeline list page.
-
Select Create multi-branch pipeline and click OK .
-
Fill in the basic information and repository details as per the instructions below.
- Name: the name of the pipeline. The pipeline name must be unique within the same workspace.
- Description: A user-defined description of the current pipeline.
- Repo URL: Provide the URL of the remote code repository.
- Credential: For private repositories, you need to create repository access credentials beforehand and select them here.
- Script Path: The absolute path of the Jenkinsfile within the code repository.
-
Set up the branch discovery policy, scan trigger, branch settings, and clone settings as per the instructions below.
- Enable Branch Discovery: the default value is .* , and branches are filtered using regular expressions.
- Enable Multi-branch Scan: When this option is enabled, any branch changes in the code repository will be synchronized.
- Scan Interval: The code repository is scanned at preset intervals to check for updates.
- Delete Old Branch: When enabled, old branches and pipelines are deleted as per the policy.
- Branch Alive Days: Defines the number of days to keep the old branch and its pipeline, after which they are deleted.
- Max Branches: Sets the number of old branches and pipelines to be retained.
- Shallow Clone: When enabled, only the latest version of the code repository is pulled. Set the clone depth (default is 1) to speed up the pull process.
- Clone Timeout: The maximum wait time when pulling code.
-
Complete the creation. After ensuring all parameters are filled in, click the OK button to finalize the creation of the multi-branch pipeline. You'll be automatically redirected to the pipeline list.
-
After creation, the pipelines corresponding to the branches that meet the conditions will be automatically triggered.
Additional Operations¶
Scan Repository¶
The Scan Repo function is used to manually trigger the discovery of new branches in the code repository.
View Scan Log¶
Displays the log of the branches found during the latest scan of the code repository.
View Branches¶
Displays the branch information obtained according to the branch discovery policy. A branch in the disabled state signifies that the latest scan results do not conform to the branch discovery strategy.