I have a repository in Azure on-prem (TFS) where all branches should trigger a pipeline when commits are made.
The azure_pipelines.yaml
file is included in each branch and I am able to automatically create a pipeline via az pipelines create
.
trigger:
batch: True
branches:
include:
- '*'
When I initialize the repo and make my first commit to master branch, the build does not seem to be linked to the pipeline:
However, once I set up the build for the master branch AND for the first development branch, then the pipelines are able to run automatically. Is there any way to automate the manual "Set up build" process via the CLI az pipelines
and link all branches to the pipeline created by az pipelines create
?
Another issue, when I "Set up build", I cannot select a pipeline that already exists. I have to create a new one, delete it, and then after this, the initial pipeline I created is correctly linked to each branch and automatically triggered as expected. Is there any workaround?
This is what it looks like when all the branches are linked to the pipeline:
Suppose you are using Azure Cloud service not DevOps On-prem(TFS) as DevOps CLI is only supported for Azure Cloud service.
Is there any way to automate the manual "Set up build" process via the CLI az pipelines and link all branches to the pipeline created by az pipelines create?
The build status badge is controlled by option Report build status
in a YAML pipeline. When you manually create the pipeline(set up the build), it's enabled by default. But for the pipelines created by az pipelines create
, it's NOT enabled by default.
To create the pipeline for each branch, you can specify the --branch
with --yml-path
for az pipelines create
command, sample as below:
az pipelines create --name 'TestBuild2' --description 'Pipeline for test project' --repository test2 --branch dev1 --repository-type tfsgit --yml-path azure-pipelines.yml
After it's done, you can edit the pipeline and enable the option, so that it will report the build status.
Another issue, when I "Set up build", I cannot select a pipeline that already exists. I have to create a new one, delete it, and then after this, the initial pipeline I created is correctly linked to each branch and automatically triggered as expected. Is there any workaround?
When you click "Set Up build", it will ask to create a new pipeline or use existing yaml. Each pipeline is separated, will not affect the setting of another pipeline, please have a double check. As stated, the build status is controlled by the option 'Report build status', you can check the option if you would like the 'link'.