I'm having trouble triggering a build from a Git tag - azure-devops

I want to trigger a build when any of the following is true:
When there is a change to a particular branch (dev) and a subset of folders was modified (paths)
When a git tag that matches a pattern (RC* or Release*) is set and a subset of folders was modified (paths)
When I add a paths statement to my yaml build template only my branch trigger fires. I am unable to trigger off of a tag. When I remove the paths statement both my branch and tag filters work.
What am I missing?
This triggers on branch = dev or tag is either RC* or Release*
trigger:
branches:
include:
- dev
tags:
include:
- RC*
- Release*
This triggers on branch = dev only.
trigger:
branches:
include:
- dev
tags:
include:
- RC*
- Release*
paths:
include:
- /site/

I can reproduce your issue here. This issue has been confirmed as a bug and move to the product team . Please follow up this case and you can vote it to increase the priority. Sorry for this inconvenience.
Below is my reproduce:
When I added the paths trigger to the yaml, I committed the READ.md file and added the tag to the commit. However, it does not fire tag trigger. After I removing the paths trigger, the tag trigger will be fire normally.

Related

Azure pipeline trigger on tags and branch

I am getting quiet confused here with Azure DevOps build pipeline and GitHub.
In my GitHub I have the following branches:
Master
Develop
My idea and intent is to have a develop pipeline that triggers on each commit to develop branch and master needs to trigger only and exclusively on tags.
So in develop branch I updated my pipelines as follow:
Development pipeline
trigger:
branches:
include:
- develop
and my master pipeline:
trigger:
batch: true
branches:
include:
- master
tags:
include:
- '*'
paths:
exclude:
- /*
Everything works fine and if I push to develop the pipeline triggers, if I create a tag in master also he pipeline works. The problem is if I create and push a tag on develop branch, automatically my master pipeline start building as well.
I don't understand this bit here. Why creating and pushing (not merging) my tag in develop branch triggers the build in master?
What I am expecting from those pipeline is that any push to development branch should trigger development pipeline, and only tags created IN master triggers master pipeline.
Please if anyone can help me to solve and understand this I will be so grateful.
And please if there is any question don't hesitate to ask.
Thank you once again
From documentation
https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/github?view=azure-devops&tabs=yaml#ci-triggers
If you specify tags in combination with branch filters, the trigger
will fire if either the branch filter is satisfied or the tag filter
is satisfied. For example, if a pushed tag satisfies the branch
filter, the pipeline triggers even if the tag is excluded by the tag
filter, because the push satisfied the branch filter.
I suppose the best way to fix it is to have different naming conventions for tags for develop and for master and then update it accordingly in Yaml.
You can also tag your master commits which you want to deploy with 2 tags, for example your current tag "v.123" and new tag "master_to_be_deployed" and then in tags include section set include only for "master_to_be_deployed" instead of "*" wildcard.
You can also try to update branches section in master pipeline with exclude section, I am almost sure it will not work acording to documentation
branches:
include:
- master
exclude:
- develop

Trigger specific build pipeline in Azure Dev Ops with single repository(.sln) having multiple projects(.csproj)

I've a single repository having visual studio solution(.sln), where I've more than one project(.csproj) in same solution(i.e. WebAPI project, WebApp project etc.)...
Now, I've created separate pipeline(s) for individual project, which trigger whenever any commit comes to my XYZ branch...(ex. through PR code merge from feature to XYZ branch)
Now, the issue is...
Whenever any commit come to any project in that repository all pipeline start building there respective projects... Here I just want to build a specific project pipeline for which the commit file(s) comes into...
You can specify file paths to include or exclude.
# specific path build
trigger:
branches:
include:
- master
- releases/*
paths:
include:
- docs
exclude:
- docs/README.md
When you specify paths, you must explicitly specify branches to trigger on. You can't trigger a pipeline with only a path filter; you must also have a branch filter, and the changed files that match the path filter must be from a branch that matches the branch filter.
Check here:
https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/azure-repos-git?view=azure-devops&tabs=yaml#ci-triggers

Azure Devops pipeline, multi branch trigger doesn't work

I'm working for the first time with Azure Devops Pipelines. I'm using a .yml file. But I can't figure out why the pipeline won't run when I checkout and push a branch from develop to "releases/*. It just won't trigger even when there are changes in src/ which are inside my new releases/newbranch
But when I merge my change from "customers/feature-branch" with customers/moa-prototype-client1/release the pipeline will run.
My trigger is:
trigger:
branches:
include:
- customers/moa-prototype-client1/release
- releases/*
paths:
include:
- src/*
- src/customers/moa-prototype-client1/*
exclude:
- '*.yml'
- src/customers/*
What can cause this?
So in short: It will trigger when I merge from Customers/Customername/Develop to Customers/Customername/Release. But won't when I merge from Develop to Releases/*
Our repo:Gitflow
From your description, it seems that this issue exists in the Release/* branch. And the customers branch could work as expected.
During my testing, I encounter a similar situation. If the Release/* branch doesn't contain the Yaml file with triggers, the changes in the release branches will not trigger the build.
For example:
Doesn't work
To solve this issue, you could copy the same yaml file from other branches to all release branches.
Then the changes in the Release branches could trigger the build successfully.
On the other hand, as Kontekst said, the Path filters are case-sensitive. You could check them at the same time.
Hope this helps
Solution: After checking the links and possible solution some users suggested, I got it to work. But I was not totaly happy whit this fix, because I wanted to run my pipeline though my .yml file and not override my triggers though the pipeline settings.
When I looked at my .yml again and noticed a space behind releases/*, I removed this space and committed this to my repo and all was working as it should!

Push Build status to GitHub

I'd like to push the build status automatically from Azure Devops to the github repository, so that pull requests can check for a build success before they can be merged.
I realise this can be done writing some custom code and calling the github status api, but there is a checkbox for it in the edit pipeline stage. It doesn't seem to work with Github though. See this image .
Other build tools like Bamboo have an out of the box plugin for doing this.
You need to define branch policy. You can read about this on my blog. You need to selected existing pipeline here in GitHub settings:
and then when you make PR you will get this:
You need to correctly define trigger options in your yaml file. For isntance:
this will run for all non master branch (with each commit pushed to GitHub pipeline will run)
for each merge to master will trigger pipeline too
trigger:
branches:
include:
- '*'
exclude:
- master
pr:
branches:
include:
- master
paths:
include:
- gated-checkin/*
exclude:
- gated-checkin/azure-pipelines.yml

Paths to specific project in trigger not working when triggered from a branch

We currently use Azure DevOps for our builds and have set up triggers for branches. We have a solution that contains multiple projects. To build a spefic project, we have included "paths" to include the project in the build.
However, when a build is triggered from a branch that is not the master branch, all projects are built. When triggering directly from the master branch, only the specific project is built (as expected).
Is there a way to set the "Paths: Include:" to build just the specific project for all branches?
YAML code for the trigger:
trigger:
branches:
include:
- master
- bugfix/*
- task/*
- feature/*
paths:
include:
- '/Project1'