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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Trigger Custom Pipeline from API OR create a deployment Edited

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

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!

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

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 May 03, 2019

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

@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.

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. 

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

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

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...

@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

@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
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,878 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you