Jirong Hu
Jirong Hu

Reputation: 2375

TFS, is there a variable for the artifact zip file name?

Is there a way to get the artifact file name easily? Looks like TFS already knows this as shown in the log below:

No path specified for search pattern: *.zip defaulting to: F:\TFS2017_Release_Agent\_work\r1\a

2017-12-08T16:38:36.8519067Z Searching for: *.zip under directory: F:\TFS2017_Release_Agent\_work\r1\a

2017-12-08T16:38:36.8519067Z Found: 1 files to extract:

2017-12-08T16:38:36.8519067Z F:\TFS2017_Release_Agent\_work\r1\a\ZFJ0_ServiceSearchPlusBuildDefn\BETALink.Service.SearchPlus\ZFJ0_BETALink10.4 DevOps_BETALink.Service.SearchPlus_1.0.0_886.zip

2017-12-08T16:38:36.8519067Z Creating destination folder: F:\TFS2017_Release_Agent\_work\r1\a\48

2017-12-08T16:38:36.8519067Z Extracting file: F:\TFS2017_Release_Agent\_work\r1\a\ZFJ0_ServiceSearchPlusBuildDefn\BETALink.Service.SearchPlus\ZFJ0_BETALink10.4 DevOps_BETALink.Service.SearchPlus_1.0.0_886.zip

2017-12-08T16:38:36.8519067Z [command]F:\TFS2017_Release_Agent\_work\_tasks\ExtractFiles_5e1e3830-fbfb-11e5-aab1-090c92bc4988\1.112.1\7zip\7z.exe x -oF:\TFS2017_Release_Agent\_work\r1\a\48 F:\TFS2017_Release_Agent\_work\r1\a\ZFJ0_ServiceSearchPlusBuildDefn\BETALink.Service.SearchPlus\ZFJ0_BETALink10.4 DevOps_BETALink.Service.SearchPlus_1.0.0_886.zip

2017-12-08T16:38:36.8987827Z 

Upvotes: 1

Views: 665

Answers (2)

Jirong Hu
Jirong Hu

Reputation: 2375

For others, I have to write a couple of lines to get the zip file name. ZFJ0_ServiceSearchPlusBuildDefn.DefinitionName is my {Artifact alias}:

$zipdir = "$(System.DefaultWorkingDirectory)\$(Release.Artifacts.ZFJ0_ServiceSearchPlusBuildDefn.DefinitionName)\$(Release.DefinitionName)"
Write-Host "zipfile directory: "$zipdir

$zipfile = Get-ChildItem -Filter *.zip "$zipdir"
Write-Host "zipfile : "$zipfile

Upvotes: 1

Daniel Mann
Daniel Mann

Reputation: 59037

An artifact isn't "a file". In your specific case, it is. But in general, an artifact can contain any number of files.

There is no way to retrieve the files present in an artifact, since an artifact can also be a pointer to a UNC share.

Upvotes: 0

Related Questions