How can I upload adk into the Bitbucket Downloads using Bitbucket Pipeline?

yoonhok January 10, 2020

I am developing an android app and it is managed on the Bitbucket. I tried to use the "Pipeline" feature of the Bitbucket.

I found some references for it.

My first step is very simple. I just want to build "APK" file and upload it into the Bitbucket Downloads

I generated the config file like below:

image: mingc/android-build-box:latest
pipelines:
  default:
    - step:        script:
          - chmod +x gradlew
          - ./gradlew assembleDebug
          - curl -X POST --user ${BB_AUTH_STRING} "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"./app/build/outputs/apk/debug/*.apk"

When I run this Pipeline, Build is successful. But the APK file is not uploaded into the "Downloads" of Bitbucket.

The error log is very simple:

+ curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"./app/build/outputs/apk/debug/*.apk"
Warning: setting file ./app/build/outputs/apk/debug/*.apk  failed!

What's wrong? What should I do?

1 answer

1 vote
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 16, 2020

Hi @yoonhok ,

you can use bitbucket-upload-file  pipe for that.

Just follow Deploy build artifacts to Bitbucket Downloads guide .

Configure your Bitbucket Pipelines with steps build and upload:

# Add this steps to your bitbucket-pipelines.yml file

- step:
name: Build Android APK
script:
- # your build command
artifacts:
- './app/build/outputs/apk/debug/your-awesome.apk'

- step:
name: Upload to Bitbucket Downloads
script
: - pipe: atlassian/bitbucket-upload-file:0.1.2 variables: BITBUCKET_USERNAME: $BITBUCKET_USERNAME BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD FILENAME: './app/build/outputs/apk/debug/your-awesome.apk' ACCOUNT: 'your-account' REPOSITORY: 'awesome-repository-name'

Please, feel free to share your pipes experience with us.

Cheers,
Alex

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events