Dirty working tree when gradle project is in a subdirectory
loetscher opened this issue · 5 comments
If the gradle build is placed in a subfolder, the plugin will result in a dirty
state.
versioning {
gitRepoRootDir = '../'
See sandbox project https://github.com/loetscher/nemerosa-git-dirty (base spring-boot initializer with the plugin)
Steps to reproduce the problem
git clone git@github.com:loetscher/nemerosa-git-dirty.git
cd nemerosa-git-dirty/server/
git status
results in:
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
The command ./gradlew versionDisplay
will identify a dirty state:
> Task :versionDisplay
[versioning] WARNING - git status:
unstaged [
7.4/daemon-30760.out.log
....
server/build.gradle
server/gradle/wrapper/gradle-wrapper.jar
]
[versioning] WARNING - the working copy has unstaged or uncommitted changes.
[version] scm = git
[version] branch = master
[version] branchType = master
[version] branchId = master
[version] commit = 91b30fd3dc3595b2316f49f159b6f93be340f08e
[version] full = master-91b30fd-dirty
[version] base =
[version] build = 91b30fd
[version] gradle =
[version] display = master-91b30fd-dirty
[version] tag =
[version] lastTag = 0.1.0
[version] dirty = true
...
Expected behaviour
The plugin does not list unstaged
changes if the git command has a clean working tree and has not dirty state.
Converting the Layout to a gradle multiproject build seems to work, if gradle is run in the project root:
https://github.com/loetscher/nemerosa-git-dirty/tree/multi-project-build
Thanks @loetscher for reporting this.
Just a remark, when I clone the repository (thanks for this btw, very much appreciated), the server/gradlew
is not executable, I had to make it executable, commit it and then the dirty suffix disappears:
chmod u+x server/gradlew
git commit -a ...
cd server
./gradlew versionDisplay
[version] scm = git
[version] branch = master
[version] branchType = master
[version] branchId = master
[version] commit = 462081b11268a4377231bf07c3205dd8cb2ab45a
[version] full = master-462081b
[version] base =
[version] build = 462081b
[version] gradle =
[version] display = master-462081b
...
All good with you now?
Hi @dcoraboeuf ,
Thanks for the quick response. I'm working on Windows (git bash) and will have a look into it. On my buildserver (linux) the gradle is executable. Maybe this is a flaw in my sanbox example...
All good with you now?
Yes. See comments below.
The local build of the current project on Windows (not the sandbox sample) still have this issue that every single file seems to be unstaged.
A crosscheck on our buildserver states the following:
gradlew is executable and using the
versioning {
...
dirtyStatusLog = true
}
flag showed that there is indeed a tmpfolder written (by jenkins?) during the build:
14:00:42 unstaged [
14:00:42 server@tmp/...
this explains the dirty workspace. After adding server@tmp
to gitignore everything works fine on our jenkins.
Thats fine for me and thanks for your support @dcoraboeuf .
Thanks for the feedback, very much appreciated.