How to coordinate deployments with pipelines?

We've been testing out Bitbucket Pipelines over the last days and so far we're quite happy with the concept and its simplicity. There is one Problem we can't solve so far: When deploying from within Bitbucket Pipelines how can we ensure that the newest build is deployed? If we have quick commits (quick depending on the time the build takes) we end up with a race between multiple builds.

Our setup is that we want every commit to the develop branch to be directly deployed to our staging environment, In our case these are usually php applications and we're using Deployer for the actual deployment.

Update Found an open issue that would fix this: https://bitbucket.org/site/master/issues/12821/sequential-pipelines-disable 

1 answer

1 vote

Hi Marcel,

You have already found the issue to which I was going to link you. It's something we're looking into and if you have any thoughts about specific features you would like there I would invite you to comment on the open ticket. The best workaround I can think of is to add a step immediately before the deployment step which checks whether there are new commits and only if there are none does it deploy. This will not eliminate race conditions and will not deploy every version, only the latest. However, it should prevent in most cases the overwriting of deployments.

git fetch origin/<release_branch_name>
git diff origin/<release_branch_name>
if [ $? == 0 ]; then ./deploymentScript; fi

Cheers,

Tom.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

427 views 6 9
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you