Andrey Kontorovich
Andrey Kontorovich

Reputation: 65

Azure Pipelines CI not triggered by pushing tags to external git

I have repository on local GitLab server of my organization and want to trigger build pipeline that then will trigger release pipeline and publish to staging/production VMs.

I've read a lot of articles at microsoft docs, SO and tons of blogs that you can trigger pipeline by tags providing branch filter like refs/tags/v*. YAML configuration has additional section special for tags, however YAML is not supported for git repos that are connected as "Other git".

And that tag trigger just never works. After I set up trigger UI shows me just "v*", so it understands that refs/tags has special meaning. I can run pipeline manually specifying exact tag, like refs/tags/v1.0-test, and it works. But never launches automatically. Branch triggers work without problems.

What I've already tried:

I tried pushing commit, then pushing tag. Tried pushing commit and tag in one requiest with git push ---follow-tags. Tried pushing tags for older commits. Nothing of that works.

This issue about the same problem was resolved on azure side previous summer, however all comments where about GitHub integrations. So maybe it's still broken for "other git" or smth else.

Any help?

Upvotes: 1

Views: 1373

Answers (1)

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30373

I tested and got the same result, tags triggers for other git doesnot work. You can submit a feature request(click suggest a feature and choose Azure devops) for supporting tag triggers for gitlab repo to Micrsoft Development team. Please check this thread for example.

As workaround you can use multiple agent jobs to achieve above currently.

You can add another agent job before your original agent job to run a script task, And add dependency on it in your original agent job. The script task will check if there is tag associated to the current commit. If the tag exits, the script task will pass, and the following agent job will run. Or the script task fails and the following agent job will be skipped.

The detailed steps is as below:

  1. add a agent job with a single powershell task. Check below screenshot. enter image description here

  2. Run below inline scripts in the powershell task to check the tags

    $tags = git describe --tags  $(Build.SourceVersion)     
    
    if($($tags) -notmatch 'v.'){exit 1} #fail the task if the tag doesnot match v*
    
  3. In the original agent job, add dependencies to above agent job.

    enter image description here

  4. Go to Triggers tab and filter all branches.

    enter image description here

Upvotes: 1

Related Questions