Powershell - New-OctopusArtifact - Artifacts giving duplicate names

(Adam Ford) #1

This is the example given on the Artifacts page to collect multiple artifacts at once.

# Collect all .xml files contained in the current working directory recursing sub-directories
Get-ChildItem . -Recurse -Include *.xml | New-OctopusArtifact

I have a script step that includes the following line:

Get-ChildItem -Path artifacts -Recurse -Include *.zip | New-OctopusArtifact

It does find every zip in the artifacts directory, but the Task page shows them all as having the same name as the first one uploaded.

For example, if the artifacts directory contains CompTracker50_DEMO.zip and CompTracker50_Dev.zip, they both get uploaded, but they are both name CompTracker50_DEMO.zip:


When I download them, they have the expected contents of both zips, i.e. one has the contents of the Dev .zip, but was named DEMO.

Am I doing something wrong here? I’m terrible at Powershell, and I can’t find any documentation on how New-OctopusArtifact works.

(Daniel Fischer) #3

Hi Adam,

Thanks for getting in touch! I’m sorry for the delay in getting back to you here. I have an alternative command which should work for you. I have just tested this on my end and it worked great.

Get-ChildItem . -Recurse -Include *.zip | ForEach-Object { New-OctopusArtifact $_ }

This command should force a new name for each .zip. As to why this is happening in the first place we are not sure yet. One of our developers are currently investigating this. :slight_smile:

Let me know if this alternative command works. If you have any further questions or thoughts here, please don’t hesitate to let me know.

Best regards,