1

We use Jalopy to reformat the code. On jenkins/svn, we checked out, formatted and commited again. Now on bamboo/stash, we want to do the same.

We set up this restriction for the master branch:

  • Prevent changes without a pull request (Everyone)

(AFAIK, it is not possible, to exclude certain users from this rule, is it?)

Now, as expected, when we try to push the formatted sources, we get this error:

remote: Branch refs/heads/master can only be modified through pull requests.        
remote: Check your branch permissions configuration with the project administrator.        
remote: ----------------------------------------------------        
remote: 
To ssh://git@mystash.com/proj/proj1.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://git@mystash.com/proj/proj1.git'

Any suggestions on how we can keep the enforcement for pull requests, while still being able to push directly to master from a Bamboo script? Or any better approach?

ratlan
  • 341
  • 2
  • 12

1 Answers1

0

That is currently correct ... kind of. The Stash UI doesn't provide a way to set this (or see if you have) at the moment. However, the REST API will actually let you set branch permissions and specify users who are exempt. For details, see this comment on the feature suggestion to add full support.

Rog
  • 4,075
  • 2
  • 24
  • 35
  • I tried the sample in the comment you mentioned, but fixed the typo in the URL (restrictions > restricted). When I POST to http://localhost:7990/rest/branch-permissions/1.0/projects/FP/repos/first-repository/restricted I get an error: java.lang.IllegalArgumentException: No enum constant com.atlassian.stash.hooks.permissions.RestrictedRef.Type.PULL-REQUEST-ONLY Besides that, how would that request differ from passing the same parameters through the UI? It seems to me that passing an username is an additional restriction rather than an exception to the restriction. – ratlan Sep 08 '15 at 10:45
  • The same API is used by the UI, the only difference is that the UI has no way to pass in the exceptions (which is what that parameter applies). – Rog Sep 09 '15 at 12:58