how to 'lock' a branch during build process

We need to 'lock' our branch_dev during the nightly build process. This is to prevent any merges during build time because if build is successful, that code line is then merged into a branch_int, at which point the branch_dev can then be 'unlocked'.

I thought I'd use the stash cli and test doing this with the updateBranchPermissions, but I get a java lang exception:

I put the wrong output, below is the correct stash cli I passed and it's output:

stash --action updateBranchPermissions --project "SCOT" --repository "ScottTestRep" --id "5" --branch "branch_dev" --userId "33"

Picked up _JAVA_OPTIONS: -Xmx512M

Exception: java.lang.NullPointerException

I can't find any error being reported in the stash logs. Am I doing something incorrect?

In short, build starts, have our jenkins builder account have branch permissions. Build is over, update branch permissions to the original branch users.

If there is a better way to about this, please let me know.

Thanks!

2 answers

1 accepted

I'm not sure about the error you're seeing. I'm guessing you're using the CLI from Bob Swift? It may be best to note issues on the marketplace page so it can be fixed. However, I expect you might be better served by using an intermediate branch. You can restrict access permanently to a pattern like automated_builds/** then before a build, create a branch off of branch_dev like automated_builds/branch_dev. You can then merge that branch to branch_int. This has the added protection of guaranteeing that no long-running pushes are hanging on after you change permissions. (I may be spitting FUD, but this is something I'd be afraid of with your suggested approach). You can delete the branch when the build is over. There may be better ways to do this (hopefully others can chime in) , but this would be my first approach. Good luck!

Thank you for that idea. I didn't even think of pushes in progress. 'll give that a try.

hi,

does we have answer to this issue or a best approach to perform this branch lock?

thanks

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

635 views 0 4
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot