Powershell - New-OctopusArtifact - Artifacts giving duplicate names

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:

Capture

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.

1 Like

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,
Daniel

Hi Daniel,
Is it possible to get config files from different targets and create a single zip file as an artifact for them?

Hi @saurabh.ghildiyal,

Sorry for the delay in replying to your question here. I think you can do this, though you will need to write some custom scripting to make it work nicely.

You can use a script that executes on each step to copy the config file from each target into a single directory and rename it. You could even use Octopus variable for the naming, something along the lines of #{Octopus.Machine.Name}.web.confg

Towards the end of the deployment, you can have a step run on the Octopus server to zip up all the config files from that directory as an artifact using something like the above command.

We also have some more details on collecting artifacts in our documentation that may be worth looking into.

Let me know if you have any further thoughts or questions on this.

Best regards,
Daniel