I'm on a project that uses TeamCity for builds.

I have a VM, and have written a PowerShell script that backs up a few files, opens a ZIP artifact that I manually download from TeamCity, and then copies it to my VM.

I'd like to enhance my script by having it retrieve the ZIP artifact (which always has the same name).

The problem is that the download path contains the build number which is always changing. Aside from requesting the download path for the ZIP artifact, I don't really care what it is.

An example artifact path might be:

> 
> http://{server}/repository/download/{project}/{build\_number}:id/{project}.zip
> 
> 
> 

There is a "Last Successful Build" page in TeamCity that I might be able to obtain the build number from.

What do you think the best way to approach this issue is?

I'm new to TeamCity, but it could also be that the answer is "TeamCity does this - you don't need a PowerShell script." So direction in that regard would be helpful.

At the moment, my PowerShell script does the trick and only takes about 30 seconds to run (which is much faster than my peers that do all of the file copying manually). I'd be happy with just automating the ZIP download so I can "fire and forget" my script and end up with an updated VM.

Seems like the smallest knowledge gap to fill and retrieving changing path info at run-time with PowerShell seems like a pretty decent skill to have.

I might just use C# within PS to collect this info, but I was hoping for a more PS way to do it.

Thanks in advance for your thoughts and advice!

Update: It turns out some other teams had been using Octopus Deploy (<https://octopus.com/>) for this sort of thing so I'm using that for now - though it actually seems more cumbersome than the PS solution overall since it involves logging into the Octopus server and going through a few steps to kick off a new build manually at this point.

I'm also waiting for the TC administrator to provide a Webhook or something to notify Octopus when a new build is available. Once I have that, the Octopus admin says we should be able to get the deployments to happen automagically.

On the bright side, I do have the build process integrated with Microsoft Teams via a webhook plugin that was available for Octopus. Also, the Developer of Octopus is looking at making a Microsoft Teams connector to simplify this. It's nice to get a notification that the new build is available right in my team chat.