I need help saving the artifacts using the bitbucket repository and saving it downloads.
How to write the code for it?
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 :
Select the Artifact tab of the pipeline result view
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Welcome to the Community!!
For an example, refer here --> https://support.atlassian.com/bitbucket-cloud/docs/use-artifacts-in-steps
Thanks,
Pramodh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.