ari / gradle-release-plugin

A modern release plugin for gradle
Apache License 2.0
51 stars 26 forks source link

plugin breaks trying to start a git process #21

Closed rutchkiwi closed 10 years ago

rutchkiwi commented 10 years ago

Hey!

This plugin works fine when running gradle locally, but when i try to run on our CI machine the build.gradle file can't be evaluated, and no gradle tasks at all works.

For example when running gradle tasks i get:

[Gradle] - Launching build.
[workspace] $ /var/lib/jenkins/jobs/Forecast-production-GRADLEase/workspace/gradlew -DBRANCH_TO_BUILD=gradle2 test

FAILURE: Build failed with an exception.

* Where:
Build file '/var/lib/jenkins/jobs/Forecast-production-GRADLEase/workspace/build.gradle' line: 47

* What went wrong:
A problem occurred evaluating root project 'forecast'.
> Process 'command 'git' finished with non-zero exit value 1

With --info & --debug (cut down to relevant parts) https://gist.githubusercontent.com/rutchkiwi/ac03d610bf48aea0abfb/raw/af6cfcd24018cd62d11a7bbe44f3da63eae554a0/relase-git-problem

Any ideas on how to fix this?

nikolaylagutko commented 10 years ago

I had the same problem with this plugin (I tried to use it with Travis-CI) and unfortunately I didn't solved it it.

The problem consist of two parts:

  1. How plugin determines name of branch. If you have a look to your log (at 4th line) - you'll see that it was executed command 'git symbolic-ref -q HEAD'. And result of this command was marked as failed.
  2. How CI servers get a code from repository. In most cases it not just a clone, but also a checkout to a specific revision (mean. git clone and git checkout) and in result you have a repo in detached head state. That's why command mentioned about was failed.

So in result we have two ways to fix it:

  1. Configure your CI server to prevent detached head.
  2. Implement alternative way to determine branch name even in detached head state (but I have no idea how to do this)
rutchkiwi commented 10 years ago

Thanks Nikolay!! That makes perfect sense.

In the end I opted to use a simpler approach, just setting the version in the gradle build file like so:

if (project.hasProperty('newVersion')) {
    version = project.newVersion
    logger.lifecycle("setting version to " + project.getVersion())
} else {
    version = '0-SNAPSHOT'
}

and doing the git tagging manually.

benfortuna commented 9 years ago

I think this shouldn't be closed as the issue isn't resolved. I am seeing the same problem trying to use this plugin with travis-ci.

ari commented 9 years ago

To me it looks as though travis just doesn't have git installed. Simple as that. I've wanted for some time now to move to jGit, but haven't yet had a chance to finish that. Take a look at the jgit branch and perhaps you might have time to assist in completing this migration?

benfortuna commented 9 years ago

Ok. As a workaround I just tried to configure travis to install Git before execution but it didn't make any difference. I'll take a look at the JGit branch when I get a chance to see if I can help. Thanks.