Taxim11
Taxim11

Reputation: 13

Acess teamcity artifact path in Powershell

I recently configured a buildserver which compiles and builds my C# solution just fine. I'm building it with MSBuild by the way, no Visual Studio is installed. So now, I want to deploy my /bin folder to another server.

So now to my Problem: At the build config I've set the follow artifact path:

src\PROJECTNAME\bin\Debug => deploy.zip

The location of the zip is: C:\TeamCity\buildAgent\system\.artifacts_cache\localhost_9191\httpAuth\repository\download\CONFIGNAME\8.tcbuildid, and there is my deploy.zip.

The thing is that I can't change the left part (C:\TeamCity\buildAgent\system\.artifacts_cache\localhost_9191\httpAuth\repository\download\CONFIGNAME), just the right part apparently.

Even if I set the <teamcity Data directory> it doesn't solve my problem, as the deep structure and variable folder name (8.tcbuild) still exists, just at another location.

So, apparently I can't create an artifact zip outside the Data folder. But there has to be a way to access the path, isn't it? I can't find a parameter, which I could use for a PowerShell script.

Could you show me a solution, how I can generate an artifact zip by TeamCity and then access and use the zip by PowerShell and, for example, copy it to another location?

Upvotes: 1

Views: 1184

Answers (1)

Didier Aupest
Didier Aupest

Reputation: 3367

You can use Artefact dependencies between two Configurations.

  1. A first configuration "Packaging" style, with an artifact rule, to create a file : deploy.zip
  2. A second configuration "Deploying" style, with an artifacts dependencies on *.zip from Packaging which will run your PowerShell.

You can specify the path of your input artifacts inside the second configuration in order to use it inside your powershell.

ie:

Artifacts Dependencies

*.zip => DeployData/

PowerShell Script

 Copy-Item DeployData/*.zip DestinationFolder

Upvotes: 1

Related Questions