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

Problem downloading artifacts using REST API

Juan Carlos Santamaria
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 26, 2024

I am using the REST API to attempt to download pipeline artifacts.

I am successfully able to list the artifacts in a build using curl and an API token:

curl -X GET -H "Authorization: Bearer <api_token>" https://<bamboo_url>/rest/api/latest/result/TASP-TASFLATLAND-114?expand=artifacts

From the response, I am able to extract the url link of the artifact: for example (notice the url is a redirect):

https://<bamboo_url>/build/result/artifactUrlRedirect.action?artifactId=960725061

 However, when I attempt to access the url I get redirected to an "authentication page" (okta).  It does not seem to matter if I use the Bearer API token or normal username/password in curl (i.e., the -u option).

Any clues on what is going on?   How can I avoid the redirect link to redirect me to the authentication page and instead provide the artifact in the request?

1 answer

2 votes
Jyothi Charupalli
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 27, 2024

Hi @Juan Carlos Santamaria ,

Welcome to the Atlassian Community!

Could you please tell us which Bamboo version you have? Because I have tried with the latest Bamboo version 9.5.0 with SSO enabled and I get the direct artifact links in the API output like below:

<artifact><name>hi_re</name><link href="https://<bamboo-url>/browse/PROJ-TEST-9/artifact/shared/hi_re/" rel="self"/><producerJobKey>PROJ-TEST-JOB1-9</producerJobKey><shared>true</shared><size>9</size><prettySizeDescription>9 bytes</prettySizeDescription><id>2949121</id></artifact><artifact>

And I was able to download the artifact using this URL "https://<bamboo-url>/browse/PROJ-TEST-9/artifact/shared/hi_re/"

Could you please provide the screenshot of Bamboo overview > Authentication methods?

Alternate Option to get artifact URL and download artifacts:

You can use this rest API endpoint: /rest/api/latest/planDirectoryInfo/PROJ-PLAN to get the artifact directory paths stored on Bamboo server.

Refer to this documentation: plan-directory-information-rest-api 

Then, add the path to the artifact to below API endpoint to download the artifacts:

/artifact/<BUILD_KEY>/path/to/artifact

 

Best Regards,

Jyothi

*please don't forget to Accept the answer if your query was answered**

Juan Carlos Santamaria
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 27, 2024

Hi Jyothi,

Thank you for your response.  I have information for you:

  • Bamboo version: /rest/api/latest/info
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><info><version>9.2.11</version><edition></edition><buildDate>2024-02-05T09:45:00.000Z</buildDate><buildNumber>90210</buildNumber><state>RUNNING</state>
  • Access /rest/api/latest/planDirectoryInfo/TASP-TASFLATLAND
    I attempted the alternate option but I discover the bearer API token does not have the privileges to access this endpoint:
{"message":"You don't have global administration permission","status-code":403}
  • Bamboo overview authentication methods:
    I am trying to get a screenshot from the bamboo admin. 

Additional information:

I think the bamboo server is using Amazon S3 as artifact handler. Let me confirm.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events