Upload files and trigger pipelines on bitbucket cloud using self-hosted windows runners
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
The Bitbucket Cloud Pipe "bitbucket-upload-file" fails with the following error message:
1
The Pipes feature is not supported on this self-hosted runner's platform" because pipes are not supported on Windows hosted Bitbucket Runners.
Environment
Bitbucket Runners - Windows
Cause
Currently, pipes are not supported by Windows self-hosted runners due to limitations on how they are implemented and security complications.
Solution
Depending on the outcome, a workaround can be achieved by executing an API call. For example, instead of using the "bitbucket-upload-file" Pipes, the same action can be achieved by executing the Upload a download artifact API:
1
curl -X POST "https://username:apppassword@api.bitbucket.org/2.0/repositories/$env:BITBUCKET_REPO_FULL_NAME/downloads" --form files="@filename.zip"
A full pipeline configuration would look like below:
1
2
3
4
5
6
7
8
pipelines:
default:
- step:
runs-on:
- 'windows'
- 'self.hosted'
script:
- curl -X POST "https://username:apppassword@api.bitbucket.org/2.0/repositories/$env:BITBUCKET_REPO_FULL_NAME/downloads" --form files="@filename.zip"
Another example can be the "trigger-pipeline" Pipes. Instead of using these Pipes, the same action can be achieved by executing Trigger a pipeline for a branch API:
1
2
3
4
5
6
7
8
$ curl -X POST -is -u username:password -H 'Content-Type: application/json' https://api.bitbucket.org/2.0/repositories/workspace/repository/pipelines/ -d '
{
"target": {
"ref_type": "branch",
"type": "pipeline_ref_target",
"ref_name": "master"
}
}'
In summary, this document discusses performing API calls using curl as an alternative to using pipes. You can refer to the API documentation to find examples for executing API calls using other programming languages like Python, Bash, etc.
Was this helpful?