0
votes

I am trying to tag the active git branch with the build number so that we can know what all code changes have got into the build. Referring to this Setting Git Tag from Azure Devops Build Pipeline on Complete I made entries in the YAML file. Below is the YAML code changes.

steps:
  - checkout: 'self'
    clean: true
    persistCredentials: true

  - script: |
      git tag Build_$(Build.BuildId)
      git push origin Build_$(Build.BuildId)
    workingDirectory: $(Build.SourcesDirectory)

The pipeline build succeeds and I am able to see the tag applied enter image description here

However, when I see the build logs I see below error. I don't understand what is the problem

[error]To https://dev.azure.com/{Org}/{Project}/_git/{Repo}

[error] * [new tag] Build_10691 -> Build_10691

Please help me fix this issue.

1
Looks like it's Git just reporting the progress to the standard error stream. Can you try and modify the git push command in your script to git push -q origin Build_$(Build.BuildId)?Yan Sklyarenko
@YanSklyarenko Consider adding that as answer instead of comment~ Just a reminder, at least in my test the -q options works like a charm to resolve the error.LoLance
@LanceLi-MSFT thanks for testing that! :)Yan Sklyarenko

1 Answers

1
votes

Git is known to report the progress status of the push command to the error stream. Search for --progress option here in the docs for more details. You can suppress this behavior supplying the -q option to the push command, like this:

git push -q origin Build_$(Build.BuildId)

According to the -q option description:

Suppress all output, including the listing of updated refs, unless an error occurs. Progress is not reported to the standard error stream.

Hope this helps.