2
votes

B"H

Simply. I'd like to build the code in a branch of my GitHub repo that is not master. I don't see any option to do that. It lets you choose which repo you want to checkout as the first step in a pipeline, but not which branch.

I see that once you've created the pipeline. There is a file azure-pipelines.yml which has a line called trigger. However

  1. It's not only which branch I want to trigger the build. It's also that I want use the code from the second branch for this build
  2. It does not give you the option to save azure-pipelines.yml in any branch other than master (or one that it will create right then for you from master)
  3. Changing the branch listed under trigger doesn't actually work. (probably because of the first two issues). It still only triggers if check into master

So how would I choose an alternate branch. Thank you.

3
i.e. I need to create a build pipline for a feature branch to build it and push it to staging for QA to see and test before I merge into masterRabbi

3 Answers

2
votes

In the YAML Editor:

  1. Go to Options (3 dots in the upper right corner)
  2. Triggers
  3. YAML
  4. Click on "Get Sources"
  5. Select your default branch under "Default branch for manual and scheduled builds"

Additonally if you queue the build manually you can edit the source branch under "Branch/tag"

1
votes

1,For classic view pipeline. Go to your pipeline, click edit to edit your pipeline, In tasks page,click Get sources, and choose default branch to build, as shown in below pic. enter image description here

2,For yaml pipeline, go to your pipeline, click the eclipse the 3 dots in the upper right corner, choose triggers, go to YAML page as shown in below pic

enter image description here enter image description here

0
votes

Go to GitHub to your branch, create a new file with the name azure-pipelines.yml, paste the yaml of your pipeline and in the trigger put the branch name.

For example, I created the file in my uwp-controls branch:

enter image description here

This is the content:

trigger:
- uwp-controls

pool:
  vmImage: 'ubuntu-latest'

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

- script: |
    echo Add other tasks to build, test, and deploy your project.
    echo See https://aka.ms/yaml
  displayName: 'Run a multi-line script'

After the commit a new pipeline created for the uwp-controls branch:

enter image description here