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

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

so what url to use for downloading the artifacts in the loop ?

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

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

 

Exactly how to use the results to build the URL? What should go where?

@Rafael Please provide more details on how the iteration is done as  there is no obvious info on what URL to use for subsequent download requests to get the artifacts, especially for plans that produce multiple artifacts

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Monday in Confluence

Organizing your space just got easier - Page Tree Drag & Drop is here

Hi Community! I’m Elaine, Confluence Product Manager. You may have read my earlier post about page tree in space navigation sidebar. I'm excited to share another improvement that helps you organize ...

159 views 3 5
Join discussion

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