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