Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Curl payload request to trigger a pipeline

Bernardo García March 2, 2023

Hi community

I want to send a curl request to trigger a pipeline in one of the repositories we managed, the curl command is this, based on the api reference docs https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pipelines/#trigger-a-custom-pipeline-with-variables 

curl -X POST -is -u "$BITBUCKET_USERNAME":"$BITBUCKET_APP_PASSWORD" \
--header 'Content-Type: application/json' \
https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/pipelines/ \
--data '
{
"target": {
"ref_type": "branch",
"type": "pipeline_ref_target",
"ref_name": "develop",
"selector": {
"type": "custom",
"pattern": "Deploy to integration"
}
},
"variables": [
{
"key": "NAMESPACE",
"value": "enrx_org_013"
},
{
"key": "URL",
"value": "https://api.xx.xxx.net/"
},
{
"key": "KID",
"value": "xxxxx"
}
],
"WAIT": true
}'

 But I got this error

{"error": {"message": "Bad request", "detail": "bitbucket-pipelines.yml not found.", 
"data": {"key": "result-service.pipeline.yml-not-found", "arguments": {}}}}

It is like the `bitbucket-pipelines.yml` wouldn't exist in the repository where I am trying to trigger the pipeline, but it does. Could be that apparently the payload I am providing on the curl command is incorrect in  somehow?
How can I get this curl request properly formed?

1 answer

1 accepted

0 votes
Answer accepted
Bernardo García March 2, 2023

Got it. At the selector attribute, in the `pattern` sub key I had to provide the name of the existing pipeline on `bitbucket-pipelines.yml` file I want to be called to be executed on the request.

I was doing this 

"selector": {
"type": "custom",
"pattern": "Deploy to integration"
}

 I need to do this


```
"selector"
: {
     "type": "custom"
     "pattern": "<pipelinename-to-be-called>"
}
```

Suggest an answer

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

Atlassian Community Events