I have a website project with two pipelines
1.- PROD pipeline, which is triggered on every master branch push. This builds the site, deploys it and sends an email to the whole company informing about the new version. This works perfectly so far ✅
2.- DEV pipeline: should be triggered on a push to ANY branch that is not master. Builds the site, deploys the site to a DEV stage and sends an email to the author of the commit.
Following the docs, this trigger configuration should trigger the DEV pipeline on all branches but master.
trigger:
branches:
exclude:
- master
include:
- '*'
However, if I then try run the pipeline in any branch that is not master, I get the following error: Encountered error(s): Could not find valid pipeline YAML file for this branch/tag
How can I setup the pipeline, so that it gets triggered by all branches but the master branch?
Thanks in advance for your help!
D
You have to have the YAML file in every branch you want it to trigger for, you cannot just have it in the master branch and expect it to trigger on another branch.
Related
What I have to do is, I have 1 branch as below in the azure DevOps respository
dev
Then I create a new branch as dev-C123456, so now I have two branches (dev and dev-C123456)
Then I do some changes to dev-C123456 and I create a Pull Request from dev-C123456 to dev. So once the changes are reviewed, the approver will Approve and Complete the pull request.
Right after he clicks Completes, I want a pipeline to run.
Here's my
And I have a auzre-piplines-on-pr.yml which will trigger the pipeline. For example, in dev branch, I have like this;
pr:
branches:
include:
- dev
...
But it never triggers a pipeline, what should I do?
Right after he clicks Completes, I want a pipeline to run.
So put a trigger for the target branch.
trigger:
branches:
include:
- dev
That will run whenever a commit is made to dev, including when the commit is a PR merge commit.
Regarding azure yml pipeline trigger
How to achieve below requirements
I want to trigger my azure yml pipeline
Should trigger pipeline on master branch if PR is merged to master branch
Should trigger pipeline on master branch if git tag is added on master branch.
Should not trigger pipeline if git tag is added on non-master branches (like develop, features branches)
Should trigger pipeline on non-master branches if PR is merged or commit happens on these branches
How to handle this any idea, I have below trigger set as of now?
trigger:
branches:
include:
- develop
- master
- features/*
paths:
exclude:
- README.md
- azure-pipelines.yml
tags:
include:
- refs/tags/*-RELEASE
In the Azure DevOps Service, the yaml build just trigger current branch, such as the .yml file in the dev branch, and add Push trigger trigger - master, then push code in the master branch, it will not trigger the build.
As a workaround, we need to update the .yml content in the different branch.
For example, If we create YAML build in the master branch, it will create azure-pipelines.yml file in the master branch.
Should trigger pipeline on master branch if PR is merged to master branch
Should trigger pipeline on master branch if git tag is added on master branch.
We can do this by adding the following push triggers
trigger:
batch: true
branches:
include:
- master
tags:
include:
- refs/tags/*-RELEASE
Should not trigger pipeline if git tag is added on non-master branches (like develop, features branches)
Should trigger pipeline on non-master branches if PR is merged or commit happens on these branches
Then create branch develop and features, it also contain the file azure-pipelines.yml, edit the file content.
trigger:
batch: true
branches:
include:
- develop #in the develop enter develop, in the feature branch, we need to update it to feature.
tags:
exclude:
- refs/tags/*-RELEASE
Update1
My current implementation of Azure pipelines is to trigger only when a pull request is made to Develop branch. But, I want to run the pipeline on every new push on any branch. How to trigger that?
My current implementation of the Azure YAML file
trigger:
- none
pr:
- branches:
include:
- dev
and below that steps are configured.
You need to specify the trigger something like this. So for example, if there is anything pushed in dev branch a build will get triggered. Ref
trigger:
- dev
or to be more explicit:
trigger:
branches:
include:
- dev
- another-branch
If no triggers are specified it will by default run for all branches. It can be explicitly defined as:
trigger:
branches:
include:
- '*'
In my case, using Azure DevOps, I have this on my .yaml file:
trigger:
- '*'
pool:
vmImage: 'windows-latest'
So, it gets triggered no matter to which branch I'm pushing to.
I hope it might help.
Note: the pool part is not relevant; I just added to give more context.
If you have git and a repo created in your project, you can easily connect git to azure dev ops. So let's say you want to deploy every push you give to the master branch of your repo. You can connect your master branch to the azure DevOps so it deploys it automatically.
This link will provide additional information
I've tried multi repo trigger using azure devops.
resources: repositories:
- repository: ToolsRepo
name: ToolsRepo
type: git
trigger:
batch: true
branches:
include:
- master
trigger does not work. It works only if I remove batch: true line. How could I make it work together with batching?
According to the test result, if you set batch: true to other repos (not the repo where the current yaml pipeline file is located), then CI trigger from other repos will not trigger the pipeline.
The CI trigger from the current repo can trigger the pipeline normally.
So I am afraid that batch: true is currently not supported in multi-repo trigger. In addition, the batch argument is not specified in the multi-repo trigger yaml syntax.
You could add your request for this feature on our UserVoice site, which is our main forum for product suggestions. The product team would provide the updates if they view it. Thank you for helping us build a better Azure DevOps.
We have a pre-deployment branch and a production branch, and would like to set security such that you can only create pull requests to the production from pre deployment and not from other branches.
How can i do this ?
Thanks
There are workaround to achieve this.
You should first create a build pipeline with a powershell task executing below script to check if the pull request source branch is the restricted branch.
$sourceBranch = "$(System.PullRequest.SourceBranch)"
if($sourceBranch -ne "refs/heads/pre-deployment")
{
exit 1
}
And then add this build pipeline to the build policy under Build validation in branch policies of your production branch. After setting above build policy, the new pull request will trigger the build pipeline and fail if the source branch is not pre-deployment
Another way to do this is creating a pull request status server. please refer to the example here for more information