Trigger build when pushing tag to git
This suggestion is migrated to Developer Community. Please use below link to view the current status.
Currently it is possible to trigger a build when pushing commits to branches, but it is not possible to trigger a build when pushing tags.
Wade Chandler commented
1) I can confirm that this works 2019-02-04 Azure DevOps, and wanted to be sure the proper info is presented here if somebody sees it (both tags created in ADO UI and git CLI and pushed):
2) I have seen some posting /refs/tags or /refs/X ... try that with your git CLI ... git checkout /refs/tags/1.0.0 (or some real tag name) ... it will fail. It is refs/tags/X ... no prefix "/"
3) I have not tried the other syntax yet, but there is the list syntax, that I'm using, and then a full syntax with include patterns etc here https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#trigger
After struggling with this issue for a while I have found that you can trigger specific tags by leaving the wildcard at the end of the tag, so for example "refs/tags/rc-*" will trigger on all tags starting with 'rc-'. Setting it to "refs/tags/*-rc" will not work
For me it works properly only when I use lightweight tags!
Has anyone managed to get this fixed?
"However, when I specify "refs/tags/*-rc*" in "Branch filters" the build is not triggered."
Same problem. Can't trigger any builds with any tag filter other then "*"
Ilya Vasilyev commented
UPDATE: the issue with "only to the head commit of the branch" was on my side. Actually it triggers the build with tag added to any commit
Ilya Vasilyev commented
refs/tags/* in "Branch filters" runs the build when tag is pushed (however only when head commit is tagged. If I create tag for some commit in the middle of "view history" - build is not started).
But I'd like to specify "refs/tags/*-rc*" for my Release build, so QA env is redeployed only when 1.1.0-rc1 tag is pushed. I don't want my QA env is redeployed when 1.1.0 is pushed on /master branch.
However, when I specify "refs/tags/*-rc*" in "Branch filters" the build is not triggered.
Did anybody try more complicated filter than "refs/tags/*" ?
@John D. Shkolnik did you manage to get the thing working?
I can get builds to trigger on tag creation but I see the same "Expected a Commit, but objectId <id> resolved to a Tag" as others are seeing.
After playing around a bit more I managed to narrow this down a bit more and builds now succeed if I don't include a tag message. As soon as I include a tag message the build once again fails as above. A fix for this would be appreciated.
Ilya Chudin commented
It trigers now by filter "refs/tags/*", but chekout tag as new branch "tags/1.2.0" and git versioning is broken, because it is not a master branch.
Thorsten Bux commented
I can confirm putting 'refs/tags/*' into the filter works for me too
Ilya Chudin commented
Have same issues as @Jaykul descibed. Without this feature i can't move my CI process to VSTS.
Istvan Darvas commented
Is this working with .vsts-ci.yml ? I have set the branch filter for "refs/tags/*" and I got this error: "Expected a Commit, but objectId <something> resolved to a Tag"
Yes it is a tag :) because i would like to trigger for that...
Can you please show me a documentation or reference or howto where I can find something to solve this?
We're using VSTS git repos
if I put /refs/head/* or /refs/tags/* (or both) it doesn't trigger at all.
if I put * (just the star) in a trigger, it builds on commits to any branch
-- I think they're prefixing whatever goes in the trigger fields with "/refs/head/"
Alexander V. R-H commented
Is this possible with a VSTS git repository?
@Tugberk I just verified that I am able to trigger a CI by using a "refs/tags/*" branch filter in my VSTS build against a GitHub repository. Please contact me and I can assist you in debugging. email@example.com
This is very surprising that I cannot trigger a build by pushing a git tag. This is majorly affecting my move to VSTS.
Tanner Watson commented
I'm experiencing the same issue today with visualstudio.com. CI trigger is set to "refs/tags/*" but the build errors out with "Expected a Commit, but objectId HASH resolved to a Tag".
It's not working for me neither with the new interface, I've got a "Expected a Commit, but objectId _commit id_ resolved to a Tag"
Simon Coy commented
This does not seem possible anymore with the new build editor
John D. Shkolnik commented
I'm also unable to get it to work. I added a trigger for "/refs/tags/*-rtm", added a tag as "0.4.0-rtm", pushed it, and nothing. I tried with a simpler trigger and still nothing.