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

How to use build artifact from one pipeline into another

Sameeksha Chepe May 11, 2022

The problem I want to solve is as follows

  • We have a frontend repo and a backend repo
  • The backend repo has the frontend build copied to a folder
  • The backend repo gets deployed to aws
  • Pipelines are set up for 
    • Building the frontend repo
    • Building and deploying the backend repo

The only missing piece is automating the frontend build copy to the backend repo. The following post solves this problem partially - it shows how to trigger the frontend pipeline from the backend pipeline. But it doesn't tell me how to use the artifacts from the triggered pipeline. 

https://community.atlassian.com/t5/Bitbucket-questions/Access-multiple-Bitbucket-repositories-from-a-single-Pipeline/qaq-p/1783419 

Can someone help me with some pointers to copy the frontend build into backend repo? 

1 answer

1 accepted

1 vote
Answer accepted
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 12, 2022

Hi @Sameeksha Chepe

Thank you for reaching out to the community.

Unfortunately, it is not possible to pass build artifacts from one Pipeline to another as it is only intended to work for steps.

As a workaround, you can use the Downloads section of your repository to upload and get build artifacts.
You can check this documentation for more information: Deploy build artifacts to Bitbucket Downloads

The idea is to upload the artifact to the Downloads section first and retrieve/download it using cURL command.
To upload, you can use the Pipes script atlassian/bitbucket-upload-file as below:

script:
  - pipe: atlassian/bitbucket-upload-file:0.3.2
    variables:
      BITBUCKET_USERNAME: $BITBUCKET_USERNAME
      BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
      FILENAME: 'build.zip'
      ACCOUNT: 'myworkspace'
      REPOSITORY: 'backend-repo'

To download the file:

curl -sL -u bb_username:app_password "https://api.bitbucket.org/2.0/repositories/workspace_id/repo_name/downloads/build.zip" --output "build.zip"

Hope it helps and let me know if you have further questions that I can help with.

Regards,
Mark C

Sameeksha Chepe May 13, 2022

Thank you very much @Mark C for this guidance. Indeed this worked well for my use-case!

The only change I did is, I uploaded the build to the frontend-repo downloads section and used the curl command in the backend-repo build. This is because the backend repo is what gets deployed, and it includes the front-end build. 

Like Mark C likes this
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 15, 2022

Hi @Sameeksha Chepe


Great! Glad to know it worked.
Yes, indeed, you can upload the artifact to either of the repositories.

Do let me know if you have further questions that I can help with and feel free to mark this question as answered as well.

Regards,
Mark C

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events