A variable to to access artifacts from a deployment in later steps

Is there currently a variable that can be accessed to find what artifacts have been created for the current deployment. Our end goal is to add links to artifacts at the end of emails for people to view instead of having some odd custom powershell email functions. Currently there is no way to get a list of artifacts to use in the each block so that a link could be created. Is there something already for this or is it not possible at the current point in time?

Hi Brent,

Thanks for getting in touch. No there is no variable that contains the list of Artifacts published during a deployment. You could add a Custom Script step and query the Octopus API for Artifacts and get the links from the Artifact Resources.

We don’t have any plans to add this concept, but you could add a suggestion to our UserVoice site.

Hope that helps!
Mike

Brent, I just tried to run this script. Can you look at this and give me an idea of the problem?

I got the following error:

VERBOSE: received -1-byte response of content type application/json;
17:21:06Info
charset=utf-8
17:21:07Error
Exception calling “DownloadFile” with “2” argument(s): "An exception occurred
17:21:07Error
during a WebClient request."
17:21:07Error
At D:\Octopus\Work\20160723002059-664\Script.ps1:35 char:5
17:21:07Error

  • $WebClient.DownloadFile("$OctopusURL/$artifactURL","$DownloadPath ...
    

17:21:07Error

  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

17:21:07Error
+ CategoryInfo : NotSpecified: (:slight_smile: [], ParentContainsErrorRecordE
17:21:07Error
xception
17:21:07Error
+ FullyQualifiedErrorId : WebException
17:21:07Error
17:21:07Error
The remote script failed with exit code 1

Ok, I figured it out. Duh, I did not have an artifact name.

How can I get all artifacts?

Hi!

Thanks for getting in touch. To get a list of artifacts using raw HTTP you need to use a GET request against the api/artifacts?regarding=<ServerTaskID> resource where this returns a paged result of artifacts for the provided server task. You can get the ServerTask ID using this Octopus System Variable: Octopus.Task.Id

Here is an example using the API against our demo server: https://demo.octopusdeploy.com/api/artifacts?skip=0&regarding=ServerTasks-249726 (note there are no artifacts for this particular deployment)

I would also recommend using our Octopus Client SDK which does a lot of the heavy lifting for you, including paginating. You can use the SDK from PowerShell, or even easier from C# or F# scripts depending on what you prefer.

Hope that helps!
Mike