I use Azure DevOps as a for CI-CD for a Salesforce project to create a scratch org for feature development. How to trigger pipeline when a branch is created in GitHub?

How to pass a part of the new branch name a variable to the pipeline? Ex: Branch Name - "Sample-GitHub-Branch", Variable to be passed in the pipeline - "Sample".

1

There are 1 best solutions below

2
On

On the base branch (i.e. main), set the CI trigger of the pipeline like as below.

trigger:
  branches:
    include:
    - '*'

Then, whenever you create a new branch (i.e. Sample-GitHub-Branch) based on the main, the pipeline will be triggered for the new branch.

In the triggered pipeline, you can use the predefined variable Build.SourceBranchName to get the branch name (Sample-GitHub-Branch). Then extract the specified sub-string from the value of it.