Forums

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

Is it possible to trigger a Pipeline Deploy step via API?

Sidney Chen July 29, 2021

I've got existing scripts to call pipelines via API to trigger the entire pipeline.

 curl -X POST -is -u user:pass \ -H 'Content-Type: application/json' \ https://api.bitbucket.org/2.0/repositories/myteam/${repo}/pipelines/ \ -d '{ "target": { "type": "pipeline_ref_target", "ref_type": "branch", "ref_name": "'$branch'", "selector": { "type": "branches", "pattern": "test-*" } } }'

Is it possible to actually call a API or a set of APIs to target the last completed pipeline for a given pattern and trigger the Deploy step only?

 

 

1 answer

0 votes
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 18, 2021

Hi @Sidney Chen ,

Thank you for reach out to the community.

I'm afraid it is not possible to trigger a Pipelines build with the last completed Pipeline for a given pattern and only trigger the step inside that build.

As a workaround, you can trigger a Pipelines build via API using a custom step.

curl -u username:password -X POST -k -H 'Content-Type: application/json' -d '{"target": {"commit": {"hash":"COMMIT_HASH_HERE","type":"commit"},"selector": {"type": "custom","pattern": "CUSTOM_STEP_HERE"},"type": "pipeline_ref_target","ref_name": "SOME_BRANCH_HERE","ref_type": "branch"}}' "https://api.bitbucket.org/2.0/repositories/workspace_id/repo_name/pipelines/"

API Documentation

To check if the last commit in your branch succeeded a Pipelines build or not, you can use the API endpoints below.
However, please note that you'll have to parse the results until you get the build statuses for a commit
To get the last commit in a branch:

curl -u username:password "https://api.bitbucket.org/2.0/repositories/workspace_id/repo_name/commits/?include=SOME_BRANCH&fields=values.hash,values.links.statuses&size=1&pagelen=1"

API Documentation

To get the build statuses for a commit:

curl -u username:password "https://api.bitbucket.org/2.0/repositories/workspace_id/repo_name/commit/SOME_COMMIT_HAS/statuses?fields=values.name,values.state,values.refname"

API Documentation

Hope it helps and let me know if you have further questions.

Regards,
Mark C

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, compass, developer experience, devex, platform engineering, internal developer platform, component catalog, atlassian learning, productivity tools, developer productivity, software architecture, compass webinar, engineering teams

Discover how Compass drives DevEx and productivity at Atlassian 🏃🏻‍♂️

Learn why Compass was built to tackle dev experience at scale. See how Atlassian uses it to boost visibility, reduce cognitive load, and drive consistency—plus tips to get started and customize your IDP for stronger team engagement.

Join the webinar ✨
AUG Leaders

Atlassian Community Events