My application's azure-pipeline.yml is using template defined in another repository.
I want to run this pipeline for 'dev' & 'master' branches under respective environment. So I have defined respective pipeline environments (DEV & PROD) in ADO > pipeline > Environment
Here under Approval & checks i added branch control so that 'dev' branch pipeline can run deploy stage in DEV environment & 'master' branch pipeline can run deploy stage in PROD environment.
My template is in another repository and has only 'master' branch.
Now when i run this pipeline for 'dev' branch it fails on check for 'Branch Control' as template file is 'master' branch. below is the error.
Check inputs:
Allowed branches:refs/heads/dev
Ensure consumed branch is protected: true
Allow deployment of branches with unknown protection state: false
<br>Verifying branch for self:
Repository: my_app_repo
Branch: refs/heads/dev
Protection status: True
Result for evaluation: Successful
<br>Verifying branch for templates:
Repository: my_template_repo
Branch: refs/heads/master
Protection status: True
Result for evaluation: Unsuccessful
<br>Check evaluation failed
How can i handle it ?
Pipeline > Environment >
DEV_ENV > Approvals & Check > Branch Control > refs/heads/dev
STG_ENV > Approvals & Check > Branch Control > refs/heads/stage
PRD_ENV > Approvals & Check > Branch Control > refs/heads/master
My pipeline should run deploy stage in a specific env passed as parameter to the template. In pipeline we are sending the Env name as parameter.
resources:
repositories:
- repository: templates
type: git
name: project_name/my_template_repo
trigger:
branches:
include:
- dev
- stage
- master
stages:
- stage: "CheckOut"
displayName: Checkout
jobs:
- job: Checkout
displayName: Checkout Application
pool:
name: $(agent_name)
workspace:
clean: all
steps:
- checkout: self
- template: template_pipeline/pipeline_template.yml@templates
parameters:
agent_name: $(agent_name)
env_name_dev: DEV_ENV<br> env_name_stg: STG_ENV<br> env_name_prod: STG_PRD