2

I have a multi-stage pipeline that is building multiple applications. I generate a common tag once per pipeline run. How do I have the pipeline update each source commit with the same tag? Using the UI tagging options causes it to only update the source repo that contains the YAML pipeline file and not any of the additional sources.

1
  • Where do you keep your code on Azure Repos, Github? Did I understand you correctly that you use multi repo in your multi stage pipeline? Commented Sep 3, 2020 at 21:34

3 Answers 3

2

How do I have the pipeline update each source commit with the same tag?

You can use git commands to create same labels and add them to every repositories.

Here is the script:

- task: CmdLine@2
  inputs:
    script: |
      git tag -a {tag} -m "{tag description}"
      git push origin --tags

If you only checkout one repository in a stage, you can add this task to the stages.

If you chekout more than one repository in a stage, switch to the corresponding directory before add the tag:

- task: CmdLine@2
  inputs:
    script: |
      cd {repository A}
      git tag -a {tag} -m "{tag description}"
      git push origin --tags
      cd ..
      cd {repository B}
      git tag -a {tag} -m "{tag description}"
      git push origin --tags
      ...

Add these tasks to all stages and you will find that the latest commits from all the repositories will be tagged.

Sign up to request clarification or add additional context in comments.

Comments

2

Citing Brady White's response from https://developercommunity.visualstudio.com/t/missing-gui-option-create-git-tag-after-successful/1007477:

  1. Edit your pipeline.
  2. From the "..." menu just to the right of the Run button, select Triggers.
  3. Select the YAML tab.
  4. Select "Get sources"
  5. From there you set "Tag sources" to Never, On success, or Always.

1 Comment

Beware using this approach, because once that "run" of the build gets housekept, the tag will be removed, as described at the end of this section: Label Sources, where it says "The tag is considered a build artifact since it is produced by the build. When the build is deleted either manually or through a retention policy, the tag is also deleted."
0

When using this approach the tags will be removed when the build is removed. So if you don't retain your builds, the tag will disappear.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.