When can I delete the file referenced by New-OctopusArtifact

I’m calling New-OctopusArtifact in a script.

The file I pass as a parameter is a temporary file, which I’d like to clean up as soon as I can, but it looks like deleting the file immediately after calling New-OctopusArtifact is too soon.

I’m seeing an error similar to "Artifact xxxxxxxx.txt not found at path 'C:\Windows\TEMP\tmpC302.tmp'. This can happen if the file is deleted before the task completes. "

David

Hi David,

Thanks for reaching out. I have had a look into how New-OctopusArtifact works and It looks like when making a call to New-OctopusArtifact, the actual collection of the artifacts doesn’t occur until the end of the deployment step. This means that any call to delete the artifact within that step will occur before Octopus actually attempts to collect the artifact.
One possible solution would be to create a new deployment step after the step in question, this new deployment step could be dedicated to cleaning up the artifacts.

I hope this helps, let me know if you have any further questions.

Kind Regards,
Tom

That makes sense.

thanks!