Reputation: 2072
I need to access the build number of the artifact within Visual Studio Team Services Release Management, so that I can send the value to a Task.
My artifact name has a space in it: "Production Branch"
I have been reading the following documentation.
The documentation states that it can be accessed like this:
RELEASE_ARTIFACTS_[source-alias]_[variable-name]
e.g.
RELEASE_ARTIFACTS_Production Branch_BUILDNUMBER
It goes on to say that if being used to pass an Argument to a task, replace the underscore with a period so:
RELEASE.ARTIFACTS.Production Branch.BUILDNUMBER
However this results in the following error:
2017-02-02T12:15:49.6988066Z ##[error]The term 'Release.Artifacts.Production_Branch.BUILDNUMBER' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
This could be due to the artifact name containing a space character and I am unsure of how to handle this.
Upvotes: 5
Views: 7875
Reputation: 29976
When you access the variable from PowerShell, you need to use "_" to replace the space in the name, for example:
Write-Host $env:RELEASE_ARTIFACTS_Production_Branch_BUILDNUMBER
But if you want to use the variable in the build task, don't change to "_", just keep using space. For example:
$(RELEASE.ARTIFACTS.Production Branch.BUILDNUMBER)
Upvotes: 3
Reputation: 33738
If you want to get it in PowerShell script, using this code instead:
$env:RELEASE_ARTIFACTS_[alias]_BUILDNUMBER
If you want to pass it as variable, using this code instead:
$(RELEASE.ARTIFACTS.[alias].BUILDNUMBER)
You can get detail variables in Download Artifacts step log:
Upvotes: 7
Reputation: 59055
It looks like you're trying to access it as an environment variable in PowerShell. In PowerShell, the appropriate way to access an environment variable is as $env:RELEASE.ARTIFACTS.Production_Branch.BUILDNUMBER
. If that's not exactly it, you can list all of the environment variables and their values with the command gci Env:
Upvotes: 0