Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

pass artifact name to argument for shell script

Jeremiah Alfrey May 6, 2019

I have a plan that generates a single artifact. It has some <random name>.bit

In another plan I import this artifact. I need to pass the name and full path of that artifact to a script. I see that you can include arguments when calling a script but I don't know the variable name for the artifacts. I read up on the bamboo variables and did not see any mention of artifacts. 

I could use shell tricks to identify the artifact name and full path but I believe bamboo should have the exact details. 

1 answer

1 accepted

0 votes
Answer accepted
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 8, 2019

Hi @Jeremiah Alfrey

You are correct, there is no variable for that specifically. Even though that is the case,  we can easily build paths with the following steps:

  1. Set a Destination path in your artifact download task (e.g. downloaded_artifacts). 
  2. All file paths could be built with:
    ${bamboo.build.working.directory}/downloaded_artifacts/*

Does that solution work for your case?

 

Assuming you consider this should be a feature in Bamboo, please feel free to raise it to our development team through https://jira.atlassian.com/issues

  1. Log in with your Atlassian user
  2. Click the Create button in the top of the page
  3. Select Bamboo (BAM) on Project field
  4. Select Suggestion on Issue Type field

 

I hope that helps.

Jeremiah Alfrey May 8, 2019

When I download an artifact from other steps. It seems to come with the complete path where it was created in the previous project. In addition I am using wild card match to retrieve the artifact. This causes me to not know the complete file name. 

some dir/some sub dir/output dir/some weird filename.bit

all I know is I got *.bit

Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 8, 2019

Got it! In this case, if the artifact path or filename does NOT have spaces I would use something like:

$(find ${bamboo.build.working.directory}/downloaded_artifacts/ -name *\.bit)

(i) This line could be used as an argument of your script.

 

If the artifact path or filename has spaces, I would use this to get them quoted:

find ${bamboo.build.working.directory}/downloaded_artifacts/ -name *\.bit > file
$(while read i; do echo \'$i\'; done < file)

(i) In this second example, the second line could be the argument of your script.

 

Let me know if that makes sense.

Jeremiah Alfrey May 8, 2019

That is essentially what I had to do. My paths do not have spaces. I only used it as an example for easy reading. 

Like Daniel Santos likes this
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 9, 2019

I'm glad you have this solved. 
In case you want to open the feature request, please let me know if you need any help.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events