how to save artifacts after builds in bitbucket ?

Neehar Pavan Chaluvadi October 20, 2022

I need help saving the artifacts using the bitbucket repository and saving it downloads. 

How to write the code for it?

2 answers

2 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 25, 2022

Hello @Neehar Pavan Chaluvadi ,

Welcome to Atlassian Community.

In order to generate artifacts in your pipeline build, you will need to add an artifacts section to your build step to define the name/patterns of files you want to be included, as in the example below : 

pipelines:
  default:
    - step:
        name: Build and test
        script:
          - npm install
          - npm test
          - npm run build
        artifacts: # defining the artifacts to be passed to each future step.
          - dist/**
          - reports/*.txt

The artifacts will be available for future steps in the same build. Artifacts are stored for 14 days following the execution of the step that produced them, and during this period you can manually download them by going to your build step and :

  1. Select the Artifact tab of the pipeline result view

  2. Click the download icon

After 14 days, the artifacts are expired. For more details please refer to Use artifacts in steps

In case you also want to upload the files generated in your build to the Downloads section of your repository, you can make use of the Bitbucket API. You would have to execute the API call as part of your build script, as in the following example : 

curl -s -u USERNAME:APP_PASSWORD -X POST https://api.bitbucket.org/2.0/repositories/<WORKSPACE>/<REPOSITORY>/downloads -F files=@hello.txt

This would upload a file named hello.txt to your repository's Downloads section. For more examples of this specific API endpoint, you're also welcome to check  Upload a download artifact.

Hope that helps! Let me know in case you have any questions.

Thank you, @Neehar Pavan Chaluvadi !

Kind regards,

Patrik S

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 25, 2022

Hey @Neehar Pavan Chaluvadi ,

We also have this step-by-step tutorial on how to deploy to Bitbucket Downloads using your pipeline build : 

Kind regards,

Patrik S

0 votes
Pramodh M
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 20, 2022

Hi @Neehar Pavan Chaluvadi 

Welcome to the Community!!

For an example, refer here --> https://support.atlassian.com/bitbucket-cloud/docs/use-artifacts-in-steps

Thanks,
Pramodh

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events