seeu1
seeu1

Reputation: 43

Deploying bitbucket artifact to downloads

I have tried uploading test coverage results from pipeline to downloads.
I have the results as an artifact folder (dir/**).
I have followed this guide: https://confluence.atlassian.com/bitbucket/publish-and-link-your-build-artifacts-872137736.html

so my bitbucket-pipelines.yml code is:

pipelines:

default:
  - step:
      name: unit tests cover report
      image: aztec2docker/polymer-testing-docker
      artifacts:
        - unit-test-cover-report**
      script:
        - npm i
        - npm run test-cover
  - step:
      name: upload
      script:
        - curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"unit-test-cover-report"

It works for single files but not for a folder.
So my question is: How do I upload a full artifact folder to bitbucket downloads?

Upvotes: 4

Views: 6988

Answers (1)

Alexander Zhukov
Alexander Zhukov

Reputation: 4557

There are a couple of way to do upload multiple files.

Option 1: create a zip or tar.gz archive from your folder and upload this archive to the downloads. There is a Bitbucket Pipe you can use to upload the file: bitbucket-upload-file

- step:
    name: upload
    script:
      - zip report.zip unit-test-cover-report-folder
      - pipe: atlassian/bitbucket-upload-file:0.1.2
          variables:
            BITBUCKET_USERNAME: $BITBUCKET_USERNAME
            BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
            FILENAME: 'report.zip'

Option 2: you can upload multiple files in a single API call,as mentioned in the Bitbucket API docs:

- curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"file-1" --form files=@"file-2"

Upvotes: 3

Related Questions