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

Trigger Custom Pipeline from API OR create a deployment

Heme April 9, 2018

The developers I work with don't want to go the Web GUI every time they need deploy to an environment. They want to do it from the command line/terminal on their machine.

I see no documented way of doing this.

Is there a way to do this yet? Can this be added as a feature?

If not, would also be nice to have a way for us to add deployment auditing via the API...

  1. We build for a lower env on our own machine
  2. Then send the info to `POST http://bbapi.com/deployments`
  3. BB is still the source of truth for deployments

 

3 answers

1 accepted

1 vote
Answer accepted
davina
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 19, 2018

Hi @Heme

You can trigger a pipeline via POST using this

https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pipelines/#post

We currently don't have a public API for deployments, if this is something you are interested in I suggest raising a feature request here.

Hope this helps!

Heme April 30, 2018

Thank you so much @davina!! Didn't know if I'd ever get a reply to this one. Any help on my other unanswered questions would greatly appreciated!

https://community.atlassian.com/t5/user/viewprofilepage/user-id/1141533

Rich Williams April 23, 2019

Hi @davina when I try requests as specified in the link you provided I receive the cryptic response:

{
    "type": "error",
    "error": {
        "message": "workspace"
    }
}

Can you provide any insight? I can't find any information on this error.

davina
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 3, 2019

I've seen this error before when there are typos in your account or repo.

Rich Williams May 24, 2019

@davina turns out is was text case in our repo  and pipeline names. Pipeline api behavior with case is different then rest of the API.

4 votes
Mike Dougherty April 18, 2018

I would also be interested in ways to trigger pipelines from an API call.

It would also be great to install a webhook that would be notified when the pipeline completes and then have access to artifacts from the build. 

rcole November 27, 2019

Couldn't you add that as a curl command in the last step of your pipeline?

0 votes
Cory Robinson May 28, 2019

I made a Node.js package that has a cli helper to trigger pipelines (ie: downstream).

How I use it is by putting a JSON file in the my common utils repo which contains the repo name of each project that wants to have their pipeline triggered when this project's pipeline is complete. I then call the cli helper in the last step of the common utils repo pipeline and it kicks off a pipeline build for all listed repos in the JSON file.

https://www.npmjs.com/package/bitbucket-utils

rcole November 27, 2019

This is cool! Any plans to extend it to also be able to run a specific pipeline in a repo?

We have a separate repo that is only infra stuff, so there are separate pipelines for running various ansible scripts. One for setting up infrastructure, one for deploying lambdas, one for deploying out backend...

Cory Robinson November 27, 2019

@rcole That would be a great idea! That actually is new to me, I wasn't aware a repo could have separate "pipelines" besides a pipeline per branch. The docs are a little lacking for pieplines stuff but I'd be really curious to know if you have any additional info that I haven't seen on the topic.

What I'm currently doing is triggering pipelines per branch with a config file ie:

const pipelineTriggers = [
{ "branch": "master", "workspace": "teamOrUser", "repo_slug": "repoName" },
  
{ "branch": "staging", "workspace": "teamOrUser", "repo_slug": "repoName" }
]
Like Ivan Lagunov likes this
Ivan Lagunov December 2, 2019

@Cory Robinson it would be useful if you extended your tool for custom pipelines indeed. You can find examples here (Trigger a custom pipeline with variables):
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pipelines/

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events