Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Upload a File from an Artifact results in PermissionError

sscholle July 15, 2025

Im using the Python Pipeline image to Build and Upload the artifact, but the Upload Step fails with a permissions error.

I have defined the Repository Variable for: BITBUCKET_ACCESS_TOKEN
with the value generated from the Access Tokens section using: Repo.read & Repo.write

The pipeline output:

 


INFO: Executing the pipe...
INFO: Current directory: /opt/atlassian/pipelines/agent/build
WARNING: This pipe accepts files only from /opt/atlassian/pipelines/agent/build or any subfolders in this path.
INFO: Start uploading 1 files ['dist/artifact.whl']...
Traceback (most recent call last):
File "/pipe.py", line 128, in <module>
pipe.run()
File "/pipe.py", line 82, in run
response = requests.post(url, auth=self.auth, files=multiple_files)
File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 115, in post
return request("post", url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 575, in request
prep = self.prepare_request(req)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 484, in prepare_request
p.prepare(
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 370, in prepare
self.prepare_body(data, files, json)
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 555, in prepare_body
(body, content_type) = self._encode_files(files, data)
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 191, in _encode_files
fdata = fp.read()
File "/pipe.py", line 119, in read
with open(self.filename, self.mode) as f:
PermissionError: [Errno 13] Permission denied: 'dist/artifact.whl'


 

 

the pipeline steps are configured here:

      - step:
          name: Build
          script:
            # grab $VERSION and substitute it in the __version__.py file
            - echo "__version__ = '${VERSION}'" > noname_trade_server/__version__.py
            - pip install build
            # install the current package
            - python -m build --wheel
          artifacts:
            - dist/*.whl

      - step:
          name: Upload to DOWNLOADS
          script:
            - pipe: atlassian/bitbucket-upload-file:0.7.4
              variables:
                BITBUCKET_ACCESS_TOKEN: $BITBUCKET_ACCESS_TOKEN
                FILENAME: 'dist/*.whl'

 
What could be the issue here?
Wrong file location?
Bad ACCESS TOKEN?

Additional Info from the 'BUILD SETUP' phase of the upload step:

 

 

+ umask 000
+ export GIT_LFS_SKIP_SMUDGE=1
+ retry 6 git clone --branch="main" --depth 50 https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/$BITBUCKET_REPO_FULL_NAME.git $BUILD_DIR
Cloning into '/opt/atlassian/pipelines/agent/build'...
+ git reset --hard 71e56e3036135e503a5affe8978206df87c72fc7
HEAD is now at 71e56e3 Tag fetching is broken on Pipelines
+ git config user.name bitbucket-pipelines
+ git config user.email commits-noreply@bitbucket.org
+ git config push.default current
+ git config http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy http://localhost:29418/
+ git remote set-url origin http://bitbucket.org/$BITBUCKET_REPO_FULL_NAME
+ git reflog expire --expire=all --all
+ echo ".bitbucket/pipelines/generated" >> .git/info/exclude
+ chmod 777 $BUILD_DIR
Artifact "dist/*.whl": Downloading
Artifact "dist/*.whl": Downloaded 8.2 KiB in 0 seconds
Artifact "dist/*.whl": Extracting
Artifact "dist/*.whl": Extracted in 0 seconds
Default variables:
BITBUCKET_BRANCH
BITBUCKET_BUILD_NUMBER
BITBUCKET_CLONE_DIR
BITBUCKET_COMMIT
BITBUCKET_GIT_HTTP_ORIGIN
BITBUCKET_GIT_SSH_ORIGIN
BITBUCKET_PIPELINES_VARIABLES_PATH
BITBUCKET_PIPELINE_UUID
BITBUCKET_PROJECT_KEY
BITBUCKET_PROJECT_UUID
BITBUCKET_REPO_FULL_NAME
BITBUCKET_REPO_IS_PRIVATE
BITBUCKET_REPO_OWNER
BITBUCKET_REPO_OWNER_UUID
BITBUCKET_REPO_SLUG
BITBUCKET_REPO_UUID
BITBUCKET_SSH_KEY_FILE
BITBUCKET_STEP_RUN_NUMBER
BITBUCKET_STEP_TRIGGERER_UUID
BITBUCKET_STEP_UUID
BITBUCKET_WORKSPACE
CI
DOCKER_HOST
PIPELINES_JWT_TOKEN
Repository variables:
BITBUCKET_ACCESS_TOKEN
SERVER_SSH_KEY
Pipeline variables:
VERSION: 0.1.11
Images used:
build : docker.io/library/python@sha256:d411270700143fa2683cc8264d9fa5d3279fd3b6afff62ae81ea2f9d070e390c
Runtime:
cloud:
version: 2
arch: x86

 

 

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 16, 2025

Hi @sscholle,

I believe this may be related to file permissions. If the access token was bad, you would see a different error. If the pipe couldn't find the file, you would also see a different error. The output of the pipe shows that the pipe can find a file and tries to upload it before it fails.

I suggest adding the the following commands in the script of your second step, right before the pipe, to check the permissions of the dist directory and of the files inside that directory.

- ls -lah
- ls -lah dist

What permissions do you see for the dist directory and the .whl files inside it?

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events