Where do downloaded artifacts go on bamboo ?
Asked by Farwa Shahid:

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 ?  

<br />


Answers:
author: Eduardo Alvarenga
body: Hello [@Farwa Shahid](/t5/user/viewprofilepage/user-id/4411832)

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:**

* <https://developer.atlassian.com/server/bamboo/rest/api-group-api/#api-api-latest-plandirectoryinfo-plankey-get>

Kind regards,

Eduardo Alvarenga  
Atlassian Support APAC

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

comments: author: Farwa Shahid
body: 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 ?


author: Eduardo Alvarenga
body: Hello [@Farwa Shahid](/t5/user/viewprofilepage/user-id/4411832)

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:**

* [Bamboo variables](https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html)

I would also recommend, instead of using a custom script to download artifacts form other plans, that you practice [Sharing Artifacts](https://confluence.atlassian.com/bamboo/sharing-artifacts-359400060.html) 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--**


Tags: artefact

download