3

referenced here already: How to access an artifact's BUILDNUMBER is Visual Studio Team Services Release management and here: https://learn.microsoft.com/en-us/vsts/build-release/concepts/definitions/release/variables?tabs=batch

I am using vanilla Visual Studio Team Foundation Server 2015 (Version 14.102.25423.0) In my build I zip up an artifact with the buildnumber of the artifact. eg. 20171004.16.zip I have two artifact sources defined in my release definition.

"QA - myproject - build"
"Prod - myproject - build"

One of my steps is to copy the buildnumber.zip file to my remote server. in my configuration setting I have defined:

ProdBuildNumber = $(Release.Artifacts.Prod - myproject - build.BuildNumber)

The issue is that ProdBuildNumber just keeps getting set as that literally. eg: from debug script:

...
2017-10-05T19:09:48.0651172Z [SYSTEM] --> [release]
2017-10-05T19:09:48.0651172Z [PRODBUILDNUMBER] --> [$(Release.Artifacts.Prod - myproject - build.BuildNumber)]
2017-10-05T19:09:48.0651172Z [RELEASE_RELEASEID] --> [114]
...

Can anyone see what I am doing incorrectly? Willing to try any ideas.

macm
  • 544
  • 7
  • 21
  • What information are you actually trying to extract? `Release.Artifacts.Prod` doesn't resolve to anything (you'd need to specify something like `Release.Artifacts.Prod.DefinitionName`, for example), and `Build.BuildNumber` will automatically resolve to the build number of the primary artifact. – Daniel Mann Oct 05 '17 at 22:25
  • Msft say to access the build number of a specific artifact is use like so Release.Artifacts.{Artifact alias}.BuildNumber. I have two artifact sources in my release. I need to be able to target the appropriate artifact Build number. Not the primary. If my alias is "some - project - name then shouldn't the path be Release.Artifacts.some - project - path.BuildNumber ??? Something in the syntax is not correct. – macm Oct 05 '17 at 22:37
  • I'd expect it's the spaces in the artifact alias that's tripping it up. It threw me for a second that you weren't trying to access `Release.Artifacts.Prod` and `Build.BuildNumber`. – Daniel Mann Oct 05 '17 at 22:39
  • Some - project - path should have been some - project - name. Cellphone error. – macm Oct 05 '17 at 22:39
  • I dunno about the spaces thing... The other post said to leave the spaces in. – macm Oct 05 '17 at 22:40
  • I'm saying to remove the spaces from **the artifact alias** *and* your attempt to reference it. – Daniel Mann Oct 05 '17 at 22:43
  • Can you give syntax sample? I don't follow. – macm Oct 05 '17 at 22:44
  • On the Artifacts tab, click the ellipsis (*...*) next to the artifact. Click "Edit". Modify the alias to be something without spaces. – Daniel Mann Oct 05 '17 at 22:46
  • I'll let you know in a few hours. Thanks for suggestion – macm Oct 05 '17 at 22:47
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/156059/discussion-between-macm-and-daniel-mann). – macm Oct 05 '17 at 23:55

2 Answers2

1

Try

ProdBuildNumber = $(Release.Artifacts.Prod) - myproject - $(build.BuildNumber)
orhtej2
  • 2,133
  • 3
  • 16
  • 26
  • I guess you'll have to use [variable expansion task](https://marketplace.visualstudio.com/items?itemName=jessehouwing.jessehouwing-vsts-variable-tasks) then, as mentioned in this answer: https://stackoverflow.com/a/36612132/7034621 – orhtej2 Oct 05 '17 at 20:14
  • The documentation seems to clearly state that you can use variables. I just can't seem to see where my syntax is incorrect. – macm Oct 05 '17 at 20:20
0

The [Release.Artifacts.Alias.BuildNumber] variable is not available in TFS2015. Upgrade your server to TFS2017 if you want to use it and you can also check all the supported variables from the Release/Logs/Deploy. Following are the supported variables in TFS2015: enter image description here

If you cannot upgrade the server for now, you can add a powershell script task in your release definition to get the detailed artifact information via Rest API.

Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60