Site icon John Folberth

Selecting Source Branches for Pipelines

Azure DevOps and Git

Background

One of benefits on leveraging YAML based pipelines in Azure DevOps (ADO), is the ability for builds and deployments to be managed as code. Even better we can select source branches for pipelines as needed. One option to even further refine this is to centralize storage of any templates being used by the build/deployment process. This can be done by storing templates in a shared repository. If unfamiliar with templates check out Microsoft’s official documentation. If looking how to implement take a look at a couple of my blog posts:  YAML Deployment Pipelines a presentation which was the evolution of Leveraging YAML Pipelines the New Deployment Architecture.

Anyone familiar with coding should be aware of the concepts on branching and merging. So how do we test changes in a centralized template repository? Some folks may adjust their pipeline to point directly to the branch in development; however, this would change it for every instance. What if there was another way?

PreReqs

Create a Branch

First step would be to create a branch in the template repository. This can be done in the User Interface (UI) by clicking “New branch”

Create a branch screen in ADO

Now we can see the second branch we created.

Resource Versions

To test any changes that may have been made to our “YAML_updates” branch we need to manual run an existing pipeline which leverages the templates we may have made changes to.

Select Run Pipeline and confirm the following screen:

Run Pipeline screen

Select “Resources” and you should see all the referenced repositories outside the repo which the pipeline is defined in:

Pipeline Resources Screen

Select the dependent repo where changes were made to a specific branch. In our case it will be “YAMLTempalates”. This will then take to a screen where you can choose which branch of the dependent repo the pipeline will pull resources from. For this example it would be feature/YAML_updates and click “Use selected version”

Resource Version Screen

Don’t be alarmed the next screen should be the Pipeline Resources screen where the only option is to click Close. This will return you to the Run Pipeline screen and click Run.

On the pipeline that is executing check the Sources section and should see the pipeline is leveraging the branch selected in the previous steps:

Pipeline Sources

Conclusion

Hopefully this helps get you started on how to better leverage and manage YAML templates and selecting source branches for pipelines. Even if you aren’t leveraging YAML templates this is just one-use case on how a pipeline can reference branches from different repositories temporarily as need be.

Exit mobile version