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

Where do downloaded artifacts go on bamboo ?

Farwa Shahid October 11, 2022

I've a python script that downloads artifacts from a bamboo job using Bamboo REST API. and then use those artifacts to further generate reports.

 

To download the artifacts,

1. I get latest job results using
https://<my-domain>/rest/api/latest/result/<jobkey with build number>?expand=artifacts

2. Use artifacts node to get href attribute of artifacts

3. hitting that href downloads the artifact.

I want to run this script on another bamboo plan. I have the plan setup and running but the only confusion I have is where will the downloaded stuff go so that I can use that?

Is there any way I can specify download location with that href hit ?


1 answer

0 votes
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 11, 2022

Hello @Farwa Shahid

Thank you for the question!

You need to call the planDirectoryInfo REST endpoint to find the folder where the artifacts are stored on the server:

For example:

$ curl -s -k -u admin:admin -H 'Accept: application/json' \
https://bamboo825.mydomain.net/rest/api/latest/planDirectoryInfo/BFMS-RT | jq

{

  "results": [
    {
      "planName": "Regression Tests",
      "isBranchBuild": false,
      "storageTag": "plan-34635781",
      "artifact_plan_roots": [
        "/var/atlassian/application-data/bamboo/shared/artifacts/plan-34635781"
      ],
      "build_log_job_roots": {
        "BFMS-RT-SSD": [
          "/var/atlassian/application-data/bamboo/shared/builds/plan-34635781-SSD"
        ],
        "BFMS-RT-REGRES01": [
          "/var/atlassian/application-data/bamboo/shared/builds/plan-34635781-REGRES01"
        ],
        "BFMS-RT-REGRES02": [
          "/var/atlassian/application-data/bamboo/shared/builds/plan-34635781-REGRES02"
        ],
        "BFMS-RT-TLA": [
          "/var/atlassian/application-data/bamboo/shared/builds/plan-34635781-TLA"
        ],
        "BFMS-RT-TR": [
          "/var/atlassian/application-data/bamboo/shared/builds/plan-34635781-TR"
        ]
      }
    }
  ]
}

Then you can apply a jq filter to capture only the artifact_plan_roots folder:

$ curl -s -k -u admin:admin -H 'Accept: application/json' \
https://bamboo825.mydomain.net/rest/api/latest/planDirectoryInfo/BFMS-RT \
| jq -r '.results[].artifact_plan_roots[]'


/var/atlassian/application-data/bamboo/shared/artifacts/plan-34635781

More information:

Kind regards,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Farwa Shahid October 11, 2022

Actually I don't have global administrative permissions to hit this endpoint.

Let me elaborate my question more
I've a plan A that runs and creates artifacts and store them as TAR file , somewhere on bamboo.

I've plan B that needs to DOWNLOAD those artifacts , extract the TAR and use data to create custom reports etc.

I've my plan B up and running which is a python script.
that downloads the artifacts the way I stated above.

import requests
requests.get(<download-link>)

downloads the file in my local Downloads folder, but when running on bamboo, where will these downloaded files go ?

Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 11, 2022

Hello @Farwa Shahid

Considering you are running the download script from a Script task. The files will be stored on the root of your build working directory. You can expand the ${bamboo.build.working.directory} variable to find the full path for the build location. Normally:

On a Local Agent:

  • <bamboo-home>/local-working-dir/${bamboo.buildKey}

On a Remote/Elastic Agent:

  • <bamboo-agent-home>/xml-data/build-dir/${bamboo.buildKey}

More information on variables:

I would also recommend, instead of using a custom script to download artifacts form other plans, that you practice Sharing Artifacts between Jobs, Plans and Deployments.

Best regards,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events