Git – Tag git version from build – tag not found in git

azure-devopsazure-pipelinesgittagging

I'm using Visual Studio Online to build a Visual Studio solution from a Team Services (was Visual Studio Online) git repository. The build happens on an on-premise build agent which is registered with Team Services, and published to Team Services.

In the "Repository" settings of the build definition, I have "Label sources" set to "On successful build", and a "Label format" specified.

The build log shows the version is tagged:

Created ref refs/tags/BuildName - SolutionName - Release_1.2.16134.03 at c1fa2a4b9e0f3365e2269bb947af7819faf40354.

And on the "Artifacts" tab of the build, it's showing "build.sourceLabel" with a hyperlink to:

refs/tags/BuildName - SolutionName ...

However when I click the hyperlink, I'm getting a TFS error:

TF401175:The version descriptor <Tag: BuildName - SolutionName - Release_1.2.16134.03 > could not be resolved to a version in the repository RepositoryName

I also can't find any tags in the local git repository:

git pull --tags
git tag

Shows nothing.

Do I need any extra steps to push my source label from the build agent up to Team Services? The top answer on this link seems to suggest what I have done is correct (however I'm not using the hosted pool).

My repository settings look like this:

Repository settings

Has anyone else had this problem? Any suggestions?

Thanks in advance.

Best Answer

This is caused by the blank space in tag name. According to the logs you provided, your build definition is named as "BuildName - SolutionName - Release", and you are using the build definition name to create the tag. This cause the blank space in tag name. Update the "Label format" to use other name format or update your build definition name to remove the blank space in it (For exmaple: BuildName-SolutionName-Release) should fix the issue.