Jens Schauder
Jens Schauder

Reputation: 81998

Why does Jenkins change my gradlew, and how to prevent that?

I'm trying to 'release' my project using the gradle release-plugin

The plugin starts by checking if my working copy is clean, so that only properly versioned stuff gets released.

This works just fine on my local machine. But when I try the same thing in a Jenkins job, the build fails complaining various stuff is changed in the workplace. I decided that a lot of stuff was just internally used by jenkins and added it to gitignore:

caches/
native/
wrapper/

But it also considers gradlew as changed:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':checkCommitNeeded'.
> You have uncommitted files:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   M gradlew
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Why does Jenkins change that file how do I prevent that?

I think the following settings on the Jenkins job might be relevant:

Upvotes: 3

Views: 3013

Answers (1)

Gluck
Gluck

Reputation: 2962

Pretty old question, but for the record to anyone coming over here, jenkins isn't at fault here, you should commit gradlew with executable bit set:

# git update-index --chmod=+x gradlew
# git commit

Then you will no longer need the jenkins setting to set it executable, which is the workaround causing your issue.

Upvotes: 9

Related Questions