At my workplace, we use a monthly release branch that's shared across several developers.
Gradle version is 2.14.1
We manually trigger the code build and release (task) using Jenkins (which is effective running - gradle clean compileJava release)
The whole process takes about 30-40 minutes, basically compiling, generating the artifacts, running Junit tests and uploading the artifacts to the Artifactory.
Eventually it comes to the step of tagging and pushing the version number: preTagCommit, which tries to update the gradle.properties and bumps up the version number to it and commits and pushes.
At this point, if there have been no commits on the branch for the last 30-40 minutes (Since the build was manually triggered), the release works successfully.
The moment there is even a single commit between the whole process it fails with error: Execution failed for task ':preTagCommit'.
*
error: failed to push some refs to 'xxx.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
*
I tried several hacks and searched the documentation but not leading to any proper solution yet.
This is how my release step looks like:
***
release {
project.setProperty("gradle.release.useAutomaticVersion", "true");
newVersionCommitMessage = "Re-snapshoted project to version "
preTagCommitMessage = "Preparing version for release "
tagCommitMessage = "Tagging Release "
tagPrefix = "calypso"
requireBranch = ""
// Sometimes the plugin trips over its own feet with modifying the gradle.properties
// then complaining it has changed.
failOnCommitNeeded = false
pushToCurrentBranch = true
}
***
Apologies if this has been asked previously, all the solution I found was general approach to git rather than from someone using Gradle-Release-Plugin with git.
Any response will be greatly appreciated.