While we are configuring CI/CD pipelines for team projects there can be requirements to configure many CI/CD pipelines. If we could maintain set of CI/CD pipeline templates, it would be very helpful when configuring extensive number of pipelines. In this blog, we are going to discuss how to configure a pipeline when the YAML pipeline templates and YAML pipeline are in two different Azure DevOps repos. Further, you would be able to learn how to build a web app code base in third repo in same team pipeline.
Pre requisites:
In this sample we use three Repos in same Azure DevOps team project. Team project name and repo names defined as follows.
WebbApp - Azure DevOps team project name
Template - Name of the repo which maintain YAML pipeline templates
ASPApp - Name of the repo which has the YAML pipeline
WebbApp - Name of the repo which has core web app code
We can define a Azure DevOps YAML pipeline to build the core app as explained in following YAML script. Let's discuss each section of the full pipeline script to get proper understanding about how to refer resources in remote repos.
variables are defined in the Azure DevOps library called "webapp" and script refer the library values.
variables:- group: webapp
Provide details of repositories which contains YAML templates and core web app code which refer from this pipeline. Provide repository name, type and branch name of both repos under resources section.
resources:repositories:- repository: Templatetype: gitname: DemoWebbApp/Templateref: main - repository: DemoWebbAppname: DemoWebbApp/DemoWebbApptype: gitref: master
Checkout the WebbApp repo to download the core app code which we going to build using the
pipeline.
- checkout: DemoWebbApp
Call temp.yml template file in Template repo using following script. Note we are referring to
template YAML with @ to indicate which repo it is coming from.
- template: temp.yml@Template
Find the full pipeline script as follows.
Once build is triggered and succeeded, you would be able to see execution page similar to following image.
This blog explained how to connect three repos in Azure DevOps team project to configure a build pipeline. Further, we learned how to configure YAML pipeline using templates in a remote git repo to build the code in another repo.
No comments:
Post a Comment