Forums

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

Cannot trigger custom bitbucket pipeline via API request

Flo Ragossnig October 20, 2023

Although, I've been through many of the related questions here, I cannot figure out what I'm doing wrong.

I've set up a test repository at https://bitbucket.org/<my-workspace>/<my-test-repo>.

Then I've added a custom pipeline (bitbucket-pipelines.yml)

image: atlassian/default-image:3

pipelines:
custom:
configure:
- variables:
- name: TENANTS
- name: STAGE
- step:
name: configure-create-and-campus
script:
- chmod +x scripts/reconfigure.sh
- scripts/reconfigure.sh some
- scripts/reconfigure.sh other

Triggering the pipeline manually from the Bitbucket Admin Interface works.

Then I've created an Access Token for the repo with pipeline:write permissions.

Then I've tried to query against the Bitbucket API endpoint, like stated in your REST API Docs via Postman. The Authorization Bearer Token has been added.

Endpoint: https://api.bitbucket.org/2.0/repositories/<my-workspace>/<my-test-repo>/pipelines/

My request body looks like so

{

"target": {

"ref_type": "branch",

"type": "pipeline_ref_target",

"ref_name": "master",

"selector": {

"type": "custom",

"pattern": "Using parameter for tenants"

}

},

"variables": [

{

"key": "TENANTS",

"value": "[\"codeversity.com\",\"sycademy.com\",\"heartbase.at\",\"tangoamadeus.com\", \"verbund.sycademy.com\",\"kaidoo.com\",\"blockademy.net\",\"oecademy.codeversity.com\",\"neeom.codeversity.com\",\"hb-tischler.heartbase.at\"]"

},

{

"key": "STAGE",

"value": "testing"

}

]

}

Unfortunately, the request I get is always

{

"error": {

"message": "Bad request",

"detail": "bitbucket-pipelines.yml not found.",

"data": {

"key": "result-service.pipeline.yml-not-found",

"arguments": {}

}

}

}

 

Any ideas? 

Any help much appreciated! 🙌

2 answers

1 accepted

0 votes
Answer accepted
Flo Ragossnig October 22, 2023

I found the solution - and I have to admit, that it pretty obvious 🙈

I have set the wrong pipeline name as a pattern:

pipelines:
custom:
configure: <-- this is the pipe name
...

so the request body should be

{

"target": {

"ref_type": "branch",

"type": "pipeline_ref_target",

"ref_name": "master",

"selector": {

"type": "custom",

"pattern": "configure" <-- this is where the name goes

}

},
...
}

Maybe this helps someone!

0 votes
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 20, 2023

@Flo Ragossnig hi. 

This is a good idea to start using pipes. Here is an example of using a trigger-pipeline pipe:

  - pipe: atlassian/trigger-pipeline:5.3.0
    variables:
      BITBUCKET_USERNAME: $BITBUCKET_USERNAME
      BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
      REPOSITORY: 'your-awesome-repo'

 

To discover more pipes, visit our Bitbucket Pipes Marketplace.

Regards, Igor

Flo Ragossnig October 20, 2023

Thanks, I've read this but unfortunately this does not solve the problem. I have set up everything already, it just does not work.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events