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
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.