user2381725
user2381725

Reputation: 31

Unable to Perform Maven Release

I am trying to Preform a Maven Release using Jenkins. But I am having some issues. This is my first time doing a Maven Release. Jenkins pulls down my code from the Git repository and changes all the pom files to the correct Version. I can see this my examining the Jenkins workspace. however it does not seem to be pushing the changes back up to the Git repo with the version changed. Git uses a code review tool call Gerrit that I should have to approve once it preforms the mvn release.

I have set SCM in my main POM <scm><developerConnection>scm:git:ssh://<user>@<IP_Address>:<Port>/<Repo_Name>.git</developerConnection></scm>

I am getting a error

Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on project <Name>: An error is occurred in the checkin process: Exception while executing SCM command. cause : An error is occurred in the checkin process: Exception while executing SCM command. Stack trace : .....

Any ideas?

Upvotes: 3

Views: 5906

Answers (2)

marq _
marq _

Reputation: 1

We're migrating our code base from SVN to BitBucket. We used to perform maven releases with no problem (from Jenkins). My recommendation is to NOT use maven-release plugin with git. It's been a nightmare. We ended up manually doing what release:prepare release:perform were supposed to do.

The requirements are as follow:

  • Jenkins job shall be executed manually.
  • It shall build a "release" artifact: -SNAPSHOT-less.
  • It shall upload it to Artifactory (libs-release).
  • It shall update the pom.xml files to prepare for the next development cycle.

On the migrated code base pom.xml files we:

On Jenkins we created a freestyle project: Perform_Maven_Release.

  • Our agent is Windows.

  • SCM: Bitbucket Server, Check out to specific local branch: master.

  • The build steps are all Windows batch commands:

  • git checkout master

  • Remove -SNAPSHOT from pom versions:

    mvn build-helper:parse-version versions:set -DnewVersion=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}

  • Upload release artifact to libs-release:

    mvn --batch-mode deploy

  • Update pom files to prepare for next development cycle:

    mvn --batch-mode build-helper:parse-version versions:set -DnewVersion=${parsedVersion.majorVersion}.${parsedVersion.nextMinorVersion}-SNAPSHOT

  • Commit and push:

    Del ".git/COMMIT_EDITMSG"
    git add pom.xml subfolder/pom.xml
    git commit -am "Committing pom.xml files for next development cycle. "
    git remote add origin https://bitbucket.com/repo/repo.git
    git push --set-upstream https://USER:PASSW@https://bitbucket.com/repo/repo.git master

Upvotes: 0

Guillaume Darmont
Guillaume Darmont

Reputation: 5018

Thanks for the pastebin.

The error Caused by: org.apache.maven.scm.ScmException: Detecting the current branch failed: fatal: ref HEAD is not a symbolic ref can often be tricked by setting Checkout/merge to local branch (optional) to master (if you're releasing master) in section Advanced... of Git parameter.

Upvotes: 1

Related Questions