The company I work for currently uses maven as a dependency
management / build tool and we are attempting to switch to gerrit to
handle secure code reviews (because of requirements from PCI
certification).
I am trying to figure out how to setup gerrit/maven/git such that we
can use the maven release plugin to tag/branch code (we tend to have
projects with multiple modules and the automated version updating is
useful).
The key issue is that users are only allowed to create annotated tags
& upload code for peer review. They do not have any branch create/
upload/delete access since this would allow them to bypass the peer
review procedure which is prohibited by PCI.
I've already figured out how to get mvn release:prepare to work (well
fool it to work) by doing the release from a local git branch named
refs/for/master (works with the release plugin version 2.1 and up).
When the tagging of the release happens the push uses
localBranch:localBranch as the destination.
I can use a similar trick for maven release:branch which gets me past
the initial update to master (change of version prior to branching,
need this or the commit part fails). Unfortunately it fails when it
attempts to push the branch (the branch is created using the ui in
gerrit so I know it exists).
The following is the maven command I've been using (update branch
versions is required or the git commit fails):
$ mvn release:branch -DbranchName=maven-test-branch -
DupdateBranchVersions=true
Unfortunately when it attempts to push to the branch it fails because
it uses the command:
$ git push ssh://
gerrit.host.name:3622/sandbox maven-test-branch
Here are some snippits from the push of what maven is doing:
...
[INFO] Executing: /bin/sh -c cd /home/jyoung/dev/gerrit-sandbox2 &&
git add -- pom.xml
[INFO] Working directory: /home/jyoung/dev/gerrit-sandbox2
[INFO] Executing: /bin/sh -c cd /home/jyoung/dev/gerrit-sandbox2 &&
git status
[INFO] Working directory: /home/jyoung/dev/gerrit-sandbox2
[INFO] Executing: /bin/sh -c cd /home/jyoung/dev/gerrit-sandbox2 &&
git commit --verbose -F /tmp/maven-scm-260241259.commit pom.xml
[INFO] Working directory: /home/jyoung/dev/gerrit-sandbox2
[INFO] Executing: /bin/sh -c cd /home/jyoung/dev/gerrit-sandbox2 &&
git symbolic-ref HEAD
[INFO] Working directory: /home/jyoung/dev/gerrit-sandbox2
[INFO] Executing: /bin/sh -c cd /home/jyoung/dev/gerrit-sandbox2 &&
git push ssh://
gerrit.host.name:3622/sandbox refs/for/master:refs/for/
master
[INFO] Working directory: /home/jyoung/dev/gerrit-sandbox2
[INFO] Branching release with the label branch-gerrit...
[INFO] Executing: /bin/sh -c cd /home/jyoung/dev/gerrit-sandbox2 &&
git branch branch-gerrit
[INFO] Working directory: /home/jyoung/dev/gerrit-sandbox2
[INFO] Executing: /bin/sh -c cd /home/jyoung/dev/gerrit-sandbox2 &&
git push ssh://
gerrit.host.name:3622/sandbox maven-test-branch
[INFO] Working directory: /home/jyoung/dev/gerrit-sandbox2
...
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] To ssh://
gerrit.host.name:3622/sandbox
[ERROR] ! [remote rejected] maven-test-branch -> maven-test-branch
(prohibited by Gerrit)
[ERROR] error: failed to push some refs to 'ssh://
gerrit.host.name:
3622/sandbox'
...
I attempted to run the command from the command line ($ git push
ssh://
gerrit.host.name:3622/sandbox maven-test-branch) and I get the
same failure.
Has anyone had luck configuring things such that maven release:branch
works without allowing users to have "update branch" permissions?
Since we only ever want to upload for peer review is there any way to
configure gerrit so that "refs/for/branch-name" is just "branch-
name"? Can this be done local git-side somehow?
I've played with local git configurations and maven configurations
with no luck. I've searched for gerrit configurations, but haven't
found any so any ideas are appreciated. The only real requirement is
that users do not get the permissions to push directly to the branch,
or otherwise skip the peer review process.
Thanks!
~Josh