Mike1991
Mike1991

Reputation: 294

TFS Release Management Artifacts Variable not available

We want to use TFS 2015.3 Release Management for Packaging/Deploying our Software. For one of our Release Tasks we need access to the Release Artifact Variables in one of our Powershell Scripts.

But everytime we try to access one of those variables RELEASE_ARTIFACTS_[source-alias]_BUILDNUMBER for example, we receive the following error message:

[error] The term 'Release_Artifacts_[source-alias]_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.

I've already tried to print out all available Environment Variables by using an inline powershell script with the following statement: Get-ChildItem Env:. But those variables weren't there anyway..

Are there any known issues when using Release Artifact variables?

Upvotes: 6

Views: 3833

Answers (2)

PatrickLu-MSFT
PatrickLu-MSFT

Reputation: 51093

You are using the pre-defined variables of the form with Release Management Artifacts:

RELEASE_ARTIFACTS_[source-alias]_[variable-name]

You need to replace [source-alias] with the name of the alias for the artifact source included in the release definition. You can find the alias name in the Artifacts tab of a release definition.

enter image description here

Then you could use it as below:

  • When used in an Inline Script parameter, periods in artifact names must be replaced with an underscore. env:RELEASE_ARTIFACTS_[ScrumProject]_[BUILDNUMBER]
  • Artifact variables can also be passed as Arguments to tasks. In this case, replace the underscore with a period: Release.Artifacts.[source-alias].[variable-name]

More details please refer this tutorial page from MSDN: Artifacts in Microsoft Release Management

After some test, got the same result as ds19. Seems release artifacts is not support for TFS2015 update3 only work with VSTS for now.


Update

You just need to specify build.artifactstagingdirectory in Publish Build Artifacts or Copy and Publish Build Artifacts step, TFS will do the thing for you. To zip the artifacts you can also use a powershell script to achieve this, more detail info you can refer this blog Manage Artifacts with TFS Build vNext

Upvotes: 3

ds19
ds19

Reputation: 3165

It seems that the Release Artifacts variables are not available for TFS on-prem; I tested the same script with VSTS and with TFS2015.3.

In VSTS release you can see the release variables in the Initialize step while in on-prem release these variables are missing:

enter image description here

enter image description here

Upvotes: 6

Related Questions