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?
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!
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;
Exception calling “DownloadFile” with “2” argument(s): "An exception occurred
during a WebClient request."
At D:\Octopus\Work\20160723002059-664\Script.ps1:35 char:5
+ CategoryInfo : NotSpecified: ( , ParentContainsErrorRecordE
+ FullyQualifiedErrorId : WebException
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?
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:
Here is an example using the API against our demo server: https://demo.octopusdeploy.com/api/artifacts?skip=0®arding=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!