Test, build a package and upload to repo Downloads
Asked by Nelson Insignares:

I have a package that I don't need to publish it into PyPi because it is for internal use only, so I wrote this pipeline that automate testing and deployment as zip file. But I need to upload it into repo downloads:

```
image: python:3.10

pipelines:
  branches:
    master:
      - step:
          name: Test and Build
          script:
            - pip install -r requirements.txt
            - pip install coverage
            - python -m coverage run -m unittest discover -v -s .\tests\ -p '*_tests.py'
            - python -m coverage report
      - step:
          name: Check coverage and build package
          script:
            - python -m coverage report --fail-under=95
            - if [[ $? -eq 0 ]]; then python setup.py sdist --formats zip; fi
            - if [[ -e dist/*.zip ]]; then echo "Zip file exists"; fi
          artifacts:
            - dist/*.zip
      - step:
          name: Deploy to repo downloads
          script:
            - pipe: atlassian/bitbucket-upload-file:0.5.0
              variables:
                FILENAME: dist/*.zip

```

It is failing to execute, I can't figure out what it is.

Thanks for your help.


Answers:
author: Patrik S
body: Hey [@Nelson Insignares](/t5/user/viewprofilepage/user-id/4461460) and thank you for reaching out to Community!

From your description, I assume the error is happening on the pipe atlassian/bitbucket-upload-file

By looking at the yml file you shared, it seems the pipe definition is lacking the required variables for authentication. As this pipe will execute API calls under the hood, you need to provide the credentials for authentication. Currently, that particular pipe supports basic authentication or access tokens, as the following examples :

* **Basic authentication** If you choose to use basic auth, you will need to provide a bitbucket **username** (which you can get from [Bitbucket Personal Settings](https://bitbucket.org/account/settings/) page) and an **[App Password](https://support.atlassian.com/bitbucket-cloud/docs/create-an-app-password/)** (you can Create an App password if you haven't already) as the credentials for authentication.   
  Permissions required for the app password - **repo:read** and **repo:write**

  ```
  script: 
    - pipe: atlassian/bitbucket-upload-file:0.5.0 
       variables: 
         BITBUCKET_USERNAME: $BITBUCKET_USERNAME 
         BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD 
         FILENAME: 'dist/*.zip'
  ```

* **Access** **Token**   

  An access token will be used for authentication. You can refer to [Access Token \| Bitbucket Cloud](https://support.atlassian.com/bitbucket-cloud/docs/access-tokens/) to create an access token. Please note that Project and Workspace access tokens are only available to Premium subscriptions.  
  Permissions required for the access token - **repo:read** and **repo:write**   

  ```
  script:  - pipe: atlassian/bitbucket-upload-file:0.5.0    variables:      BITBUCKET_ACCESS_TOKEN: $BITBUCKET_ACCESS_TOKEN      FILENAME: 'dist/*.zip'
  ```

For more details and additional examples on the configuration of that pipe, you can refer to its official documentation below :

* [atlassian/bitbucket-upload-file](https://bitbucket.org/product/features/pipelines/integrations?p=atlassian/bitbucket-upload-file)

You can try using the suggestion above to include the authentication and let us know how it goes!

If you are still facing the error after those changes, please share with us what exact command/section is erroring out and which is the full error log, so we can assist you further.

Thank you, [@Nelson Insignares](/t5/user/viewprofilepage/user-id/4461460) !

Patrik S


Tags: bitbucket-cloud

bitbucket-pipelines

cloud