Problem with sudo cp an artifact to another location: No such file

I would like to sudo cp the downloaded artifact into the final deployment location. Unfortunately cp complains that it cannot find the file but looks in the very same working directory. Due to a debugging session I also insert a ls-debug task between artifact download and sudo cp. The file is there. Can anybody help me to solve this?


Snippets from the build log:

Preparing to download plan result TSDE-TSDE-1 artifact: Shared artifact: [TSDE Distribution Artifact], pattern: [Tomatenstau-de-*.tar.gz]
Artifact [TSDE Distribution Artifact] downloaded successfully in 0s to working directory
Finished task 'Download release contents' with result: Success
Starting task 'DEBUG' of type 'com.atlassian.bamboo.plugins.scripttask:task.builder.script'
-rw-r--r-- 1 atlassian atlassian 9.1M Sep 17 10:53 Tomatenstau-de-0.001.tar.gz
Finished task 'DEBUG' with result: Success
Starting task 'Copy distribution artifact to the deplyment stage' of type 'com.atlassian.bamboo.plugins.scripttask:task.builder.command'
cp: cannot stat `Tomatenstau-de-*.tar.gz': No such file or directory
Failing task since return code of [/usr/bin/sudo cp -f Tomatenstau-de-*.tar.gz /home/meik/] was 1 while expected 0
Finished task 'Copy distribution artifact to the deplyment stage' with result: Failed

2 answers

1 accepted

1 vote

Your Copy distribution artifact to the deplyment stage task is a Command task. Arguments to Command task are not shell expanded, it means that you are actually executing a command that you'd write in the shell like this:

/usr/bin/sudo cp -f 'Tomatenstau-de-*.tar.gz' '/home/meik/'

and of course you don't have a file named Tomatenstau-de-*.tar.gz

I'd suggest using script task for the other task as well.

I use the script task an it works. Please let the PM notice that this information would have a major value when mention it within the script task box.

Thx for the suggestion, I passed it to our tech writer.

0 vote

that ls-debug - are you running it through sudo?


No. Do you think sudo is changing working directory? I will try it too.

{{sudo ls -ahl}} will produce the same output as the normal {{ls -ahl}} does.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Renan Battaglin
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,455 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you