Bitbucket API v2 - How to enabled pipelines via api?

giantoctopus March 9, 2021

Hi all,

 

I'm trying to automate my bitbucket repo creation via a bash script and am stuck on the following endpoint

/2.0/repositories/{workspace}/{repo_slug}/pipelines_config

 

I'm trying the following:

curl -X PUT -v -u "$BITBUCKET_AUTH_EMAIL":"$BITBUCKET_AUTH_PASS" -H "Content-Type: application/json" \
https://api.bitbucket.org/2.0/repositories/$BITBUCKET_USER/$REPO_SLUG/pipelines_config -d \
'{
"enabled": true
}'

 

which I thought would be the same as going 'Repository Settings > Pipeline > Settings > Enable Pipeline'



but this returns :

{"type": "error", "error": {"message": "Resource not found"}}

 

I've also tried a few variations:

curl -X PUT -v -u "$BITBUCKET_AUTH_EMAIL":"$BITBUCKET_AUTH_PASS" -H "Content-Type: application/json" \
https://api.bitbucket.org/2.0/repositories/$BITBUCKET_USER/$REPO_SLUG/pipelines_config -d \
'{
"enabled": true
}'
curl -X PUT -v -u "$BITBUCKET_AUTH_EMAIL":"$BITBUCKET_AUTH_PASS" -H "Content-Type: application/json" \
https://api.bitbucket.org/2.0/repositories/$BITBUCKET_USER/$REPO_SLUG/pipelines_config -d \
'{
"enabled": true,
"type": "repository_pipelines_configuration"
}'

 

but these also return the above result.

 

Other than that i've been able to setup pipeline vars & pipeline key pair without any issues so any help pointing me in the right direction would be appreciated.

2 answers

1 accepted

1 vote
Answer accepted
giantoctopus March 11, 2021

After contacting support the issue was resolved by using the users Bitbucket username instead of 

BITBUCKET_AUTH_EMAIL

in the authentication.

0 votes
ktomk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 9, 2021

Can confirm to reproduce if my app-password has all the needed rights.

If not, I get an error message back telling me which rights are missing. However if I try to change that (e.g. wrong repository slug), the error message stays the same, only for credentials.

The missing resource error is only shown if credentials are fine. I have no idea why it does not work. Also tried with GET first.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events