gerrit and maven release

1,275 views
Skip to first unread message

andy_w

unread,
Nov 3, 2011, 12:34:30 PM11/3/11
to Repo and Gerrit Discussion
Hi,

I'm trying to setup and understand an end-to-end git-gerrit-jenkins
maven scenario.

What I've created so far is:

- developers checkout sources from git
- developers commit and push to gerrit
- jenkins triggers ci builds and deploy snapshots to nexus
- developers make additional reviews in gerrit and submit changes

Now I'm stuck at the release process:

- I wanted to take advantage of the maven release plugin and more
specific the jenkins maven release plugin, so that a developer can
trigger the release with a jenkins job which also deployes the release
to the nexus repository.
- Now I assume: because any change goes through gerrit code review,
the release plugin also has to push its pom changes through gerrit. Am
I right?

So in my pom I define the corresponding developerConnection for
gerrit:
<scm>
<url>http://git.foobar.corp/SANDBOX/andreas/
foobar.git</url>
<connection>scm:git:git://git.foobar.corp/SANDBOX/
andreas/
foobar.git</connection>
<developerConnection>scm:git:ssh://git.foobar.corp:
29418/SANDBOX/
andreas/foobar.git</developerConnection>
</scm>

Now when triggering a release job, maven is unable to
checkin the updated poms.

<snip>
Caused by: org.apache.maven.shared.release.ReleaseExecutionException:
An error is occurred in the checkin process: Exception while executing
SCM command.
at
org.apache.maven.shared.release.phase.ScmCommitPhase.checkin(ScmCommitPhase.java:
128)
at
org.apache.maven.shared.release.phase.ScmCommitPhase.execute(ScmCommitPhase.java:
109)
at
org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:
203)
at
org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:
140)
at
org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:
103)
at
org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:
211)
... 30 more
Caused by: org.apache.maven.scm.ScmException: Exception while
executing SCM command.
at
org.apache.maven.scm.command.AbstractCommand.execute(AbstractCommand.java:
63)
at
org.apache.maven.scm.provider.git.AbstractGitScmProvider.executeCommand(AbstractGitScmProvider.java:
289)
at
org.apache.maven.scm.provider.git.AbstractGitScmProvider.checkin(AbstractGitScmProvider.java:
215)
at
org.apache.maven.scm.provider.AbstractScmProvider.checkIn(AbstractScmProvider.java:
354)
at
org.apache.maven.shared.release.phase.ScmCommitPhase.checkin(ScmCommitPhase.java:
124)
... 35 more
Caused by: org.apache.maven.scm.ScmException: Detecting the current
branch failed: fatal: ref HEAD is not a symbolic ref

at
org.apache.maven.scm.provider.git.gitexe.command.branch.GitBranchCommand.getCurrentBranch(GitBranchCommand.java:
144)
at
org.apache.maven.scm.provider.git.gitexe.command.checkin.GitCheckInCommand.createPushCommandLine(GitCheckInCommand.java:
185)
at
org.apache.maven.scm.provider.git.gitexe.command.checkin.GitCheckInCommand.executeCheckInCommand(GitCheckInCommand.java:
125)
at
org.apache.maven.scm.command.checkin.AbstractCheckInCommand.executeCommand(AbstractCheckInCommand.java:
53)
at
org.apache.maven.scm.command.AbstractCommand.execute(AbstractCommand.java:
59)
... 39 more
channel stopped
<snap>

Is there maybe another (better) release strategy than pushing the
release change through gerrit.

I think from the gerrit point of view, its not a good practice to make
changes directly in gerrits upstream. What do you think?

Thanks in advance.
Andy

Swindells, Thomas

unread,
Nov 3, 2011, 12:48:47 PM11/3/11
to andy_w, Repo and Gerrit Discussion
We have this workflow and we allow Jenkins/the release plugin user to have push
rights direct onto the branch.
We trust the release plugin to update the poms correctly and for developers to
trigger the release as the appropriate time so there isn't really any need or point
for a code review. This also skirts round the issue that it isn't easy to get the release
plugin to generate a change id - which we require all developers to include.

I can't remember if it is for this or something else but we also had to add an extra
build step to force the checkout to be on master which may resolve the exception
you are having:

git checkout master || git checkout -b master
git reset --hard origin/master


Hope that helps,

Thomas

> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en


**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postm...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************

andy_w

unread,
Nov 3, 2011, 1:25:18 PM11/3/11
to Repo and Gerrit Discussion
Hi Thomas,

you are absolutely right. I was not yet thinking of the issue with
change ids etc. So I will also go into direction of pushing changes
from release job directly to the repository.

You were also right regarding the error, because switching the gerrit
url in the developerConnection to the direct git repos did not solve
it. However, I'm wondering where you put the git commands in the
jenkins release job. Wanna gimmie another hint/screenshot/jobxml for
that.

Thanks again for you quick help.
Andreas
> > More info athttp://groups.google.com/group/repo-discuss?hl=en
>
> **************************************************************************************
> This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

andy_w

unread,
Nov 3, 2011, 1:40:54 PM11/3/11
to Repo and Gerrit Discussion
Nevermind.

Had to add your git commands as pre build task. I first tried as post
build. Sorry about mail traffic.

Now struggling around with

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare
(default-cli) on project TestParent: Unable to commit files
Provider message:
The git-push command failed.
Command output:
error: unpack failed: unpack-objects abnormal exit
To git://git.foobar.corp/SANDBOX/andreas/foobar.git
! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to 'git://git.foobar.corp/SANDBOX/
andreas/foobar.git'

any idea?

Andreas

unread,
Nov 3, 2011, 6:09:44 PM11/3/11
to Repo and Gerrit Discussion
Problem was related to ACLs of git folder respectively git-daemon had
not write access to the git repository.

Since I got another issue now, I interested in which git tooling you
use for hosting git repositories.

The issue I face is described here:
http://mail-archives.apache.org/mod_mbox/maven-users/201108.mbox/%3C1561963.013127746...@mail.deventm-group.org%3E

The maven-release plugin simply cuts the URL when executing 'git
push'.

Watch my log here:
http://codeupload.com/4542

...
Line 25: [INFO] Executing: /bin/sh -c cd /srv/jenkins/data/jobs/
reference.release/workspace/TestParent && git push
git://git.foobar.corp/SANDBOX/andreas/foobar.git master:master
...
Line 32: [INFO] Executing: /bin/sh -c cd /srv/jenkins/data/jobs/
reference.release/workspace && git push git://git.foobar.corp/SANDBOX/andreas
TestParent-0.0.6
...

the second git URL misses the end.

Anyone got an idea?
> > > ***************************************************************************­***********
> > > This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.
>
> > > NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
> > > ***************************************************************************­***********- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -
Reply all
Reply to author
Forward
0 new messages