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

Adding variables to REST API using curl

Roopesh July 14, 2019

I have created a small script to trigger a pipeline using the test API 

I am trying to run this script with the ref_name and pattern as arguments to the script 

#test.sh master deploy 

#vi test.sh 

curl -X POST -is -u $BB_USER:$BB_PASS \
-H 'Content-Type: application/json' \
https://api.bitbucket.org/2.0/repositories/transportfornsw/tfnsw-corp-tests/pipelines/ \
-d '
{
"target": {
"type": "pipeline_ref_target",
"ref_type": "branch",
"ref_name": "$1",
"selector": {
"type": "custom",
"pattern": "$2"
}
}
}'

Tried few ways to take the arguments into the script but I get an error as below 

{"error": {"message": "Not found", "detail": "Could not find last reference for branch $1", "data": {"key": "result-service.pipeline.reference-not-found", "arguments": {"uuid": "$1"}}}}

I want to add this as a part of pipeline 

thanks a lot for your help in advance 

1 answer

0 votes
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 16, 2019

Hello @Roopesh ,

In your case, you can use pipe trigger-pipeline.

Just add the following snippet to the script section of your bitbucket-pipelines.yml file:

  - pipe: atlassian/trigger-pipeline:3.1.0
    variables:
      BITBUCKET_USERNAME: $BITBUCKET_USERNAME
      BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
      REPOSITORY: 'your-awesome-repo'
      BRANCH_NAME: 'master'
      CUSTOM_PIPELINE_NAME: 'deployment-pipeline'


More available pipes you can discover here.

Cheers,
Alex

Roopesh July 16, 2019

cool , thank you Alex 

Jira Police October 3, 2019

I'm trying to get this to work. I have a question regarding the `BITBUCKET_APP_PASSWORD`. Am I supposed to actually have the line

BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD

Or am should I replace  `$BITBUCKET_APP_PASSWORD` with the app password I created?

With the app password explicitly in the yml file it works, the way you posted it it doesn't.

BITBUCKET_APP_PASSWORD:- null value not allowed

I'm not sure it's a good idea to have the app password in the file explicitly.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events