Is there a way to download the artifacts using API?

I can access the artifacts for a build using:

<PlanKey>?buildstate=Successful&max-results=1&expand=results.result.artifacts

 

Result something like:

<artifacts start-index="0" max-result="2" size="2">
 <artifact>
<name>DACPAC</name>
<link href="http://<link>/artifact/shared/DACPAC/" rel="self"/>
<producerJobKey>REG-SQL-JOB1-10</producerJobKey>
<shared>true</shared>
<size>945514</size>
<prettySizeDescription>923 KB</prettySizeDescription>
</artifact>
</artifacts>

...

However, is it possible then to download the artifacts from the artifact link result without resorting to some sort of HTML scraping?

 

2 answers

0 votes

Hello Ruban,

Thank you for your question.

This is the REST API call associated to Artifacts /plan/{projectKey}-{buildKey}/artifact which will provide you with the following output:

&lt;artifacts expand="artifacts"&gt;
	&lt;link href="[bamboo-base-url]/rest/api/latest/plan/[projectKey]-[buildKey]/artifact" rel="self"/&gt;
	&lt;artifacts start-index="0" max-result="1" size="1"&gt;
		&lt;artifact&gt;
			&lt;id&gt;1081345&lt;/id&gt;
			&lt;name&gt;Greeting&lt;/name&gt;
			&lt;location/&gt;
			&lt;copyPattern&gt;*.txt&lt;/copyPattern&gt;
			&lt;shared&gt;true&lt;/shared&gt;
		&lt;/artifact&gt;
	&lt;/artifacts&gt;
&lt;/artifacts&gt;

It will be required to iterate through the result(s) above and use it to build the URL to download the files.

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

Hi Rafael, this doesn't seem to work for me. http://builder:8085/rest/api/latest/plan/UTILS-SVNPERM/artifact?expand=artifacts should return my lone artifact definition but I get <artifacts expand="artifacts"><link href="http://builder:8085/rest/api/latest/plan/UTILS-SVNPERM/artifact"; rel="self"/><artifacts start-index="0" max-result="0" size="0"/></artifacts> Any clue what I'm missing?

Oh, that ONLY works for share artifacts.Verified by looking at source and experimentation. Ok, I must share my artifacts to be able to use this call

OK I can see it will give the artifact but how can i use this to download all the artifacts associated with the plan?

In fact, how is this more useful than the original API url I was using in the question?

http://<URL>/rest/api/latest/result/<[projectKey]-[buildKey]>?buildstate=Successful&max-results=1&expand=results.result.artifacts

Hello Ruban, "-- However, is it possible then to download the artifacts from the artifact link result without resorting to some sort of HTML scraping?" No, as mentioned earlier, it will be required to write a script to loop trough the results and download the artifacts. — Kind regards, Rafael P. Sperafico Atlassian Support

Suggest an answer

Log in or Join to answer
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,083 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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot