Hudson doesn't checkout the master branch. Hudson uses an 'unnamed' branch therefore:

      Detecting the current branch failed: fatal: ref HEAD is not a symbolic ref

      Hmm - dunno how to resolve that. Perhaps the Git plugin should handle the checkout different ... But nevertheless the issue surfaces here

          [JENKINS-5856] Unable to Release a Git Project

          Andrew Bayer added a comment -

          Preliminary work on tweaking the git plugin to checkout to an optional local branch (for JENKINS-6856 as well as this) is up at http://github.com/abayer/Hudson-GIT-plugin/tree/JENKINS-6856, if anyone wants to take a look.

          Andrew Bayer added a comment - Preliminary work on tweaking the git plugin to checkout to an optional local branch (for JENKINS-6856 as well as this) is up at http://github.com/abayer/Hudson-GIT-plugin/tree/JENKINS-6856 , if anyone wants to take a look.

          Andrew Bayer added a comment -

          Sending this back to m2release - it should work now from the git plugin side of things.

          Andrew Bayer added a comment - Sending this back to m2release - it should work now from the git plugin side of things.

          James Nord added a comment -

          Still not working, relavent sections are:

          <pre>
          Checkout:proj-app_commit / /home/hudson/data/workspace/proj-app_commit - hudson.remoting.Channel@1c17335:cabci-cf-rh5-x64-01
          Using strategy: Default
          Last Built Revision: Revision ec90272fc4b0def86159148588e4f9d602b256dc (origin/master)
          Checkout:proj-app_commit / /home/hudson/data/workspace/proj-app_commit - hudson.remoting.LocalChannel@a90942
          GitAPI created
          Fetching changes from the remote Git repository
          Fetching upstream changes from ssh://user@mygerritserver:29418/cms/proj/proj-app.git
          [proj-app_commit] $ git fetch -t ssh://user@mygerritserver:29418/cms/proj/proj-app.git +refs/heads/:refs/remotes/origin/
          [proj-app_commit] $ git ls-tree HEAD
          Seen branch in repository origin/master
          Commencing build of Revision ec90272fc4b0def86159148588e4f9d602b256dc (origin/master)
          GitAPI created
          Checking out Revision ec90272fc4b0def86159148588e4f9d602b256dc (origin/master)
          [proj-app_commit] $ git checkout -f ec90272fc4b0def86159148588e4f9d602b256dc
          [proj-app_commit] $ git tag -a -f -m "Hudson Build #36" hudson-proj-app_commit-36
          Recording changes in branch origin/master
          [proj-app_commit] $ git whatchanged --no-abbrev -M --pretty=raw ec90272fc4b0def86159148588e4f9d602b256dc..ec90272fc4b0def86159148588e4f9d602b256dc
          Parsing POMs

          <snip>

          [INFO] Executing: /bin/sh -c cd /home/hudson/data/workspace/proj-app_commit && git add pom.xml proj-bp/pom.xml proj-bp/proj-bp-adiSupport/pom.xml proj-bp/proj-bp-content/pom.xml proj-bp/proj-bp-offer/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-base/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-interface/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-mercury/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-mock/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-xti/pom.xml proj-bp/proj-bp-publishing/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-base/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-interface/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-mercury/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-mock/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-xti/pom.xml proj-definitions/pom.xml proj-definitions/proj-definitions-commonSpring/pom.xml proj-definitions/proj-definitions-packWorkflow/pom.xml proj-definitions/proj-definitions-classificationWorkflow/pom.xml proj-definitions/proj-definitions-ingestWorkflow/pom.xml proj-platform/pom.xml proj-platform/proj-platform-dataEventNotifier/pom.xml proj-platform/proj-platform-workflowSupport/pom.xml proj-platform/proj-platform-status/pom.xml proj-externals/pom.xml proj-externals/proj-externals-gateway/pom.xml proj-platform/proj-platform-applicationHost/pom.xml proj-packaging/pom.xml
          [INFO] Working directory: /home/hudson/data/workspace/proj-app_commit
          [INFO] Executing: /bin/sh -c cd /home/hudson/data/workspace/proj-app_commit && git status
          [INFO] Working directory: /home/hudson/data/workspace/proj-app_commit
          [INFO] Executing: /bin/sh -c cd /home/hudson/data/workspace/proj-app_commit && git commit --verbose -F /tmp/maven-scm-1512028766.commit pom.xml proj-bp/pom.xml proj-bp/proj-bp-adiSupport/pom.xml proj-bp/proj-bp-content/pom.xml proj-bp/proj-bp-offer/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-base/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-interface/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-mercury/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-mock/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-xti/pom.xml proj-bp/proj-bp-publishing/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-base/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-interface/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-mercury/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-mock/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-xti/pom.xml proj-definitions/pom.xml proj-definitions/proj-definitions-commonSpring/pom.xml proj-definitions/proj-definitions-packWorkflow/pom.xml proj-definitions/proj-definitions-classificationWorkflow/pom.xml proj-definitions/proj-definitions-ingestWorkflow/pom.xml proj-platform/pom.xml proj-platform/proj-platform-dataEventNotifier/pom.xml proj-platform/proj-platform-workflowSupport/pom.xml proj-platform/proj-platform-status/pom.xml proj-externals/pom.xml proj-externals/proj-externals-gateway/pom.xml proj-platform/proj-platform-applicationHost/pom.xml proj-packaging/pom.xml
          [INFO] Working directory: /home/hudson/data/workspace/proj-app_commit
          [INFO] Executing: /bin/sh -c cd /home/hudson/data/workspace/proj-app_commit && git push
          [INFO] Working directory: /home/hudson/data/workspace/proj-app_commit
          [TASKS] Skipping non-existent folder '/home/hudson/data/workspace/proj-app_commit/src/main/java'...
          [TASKS] Skipping non-existent folder '/home/hudson/data/workspace/proj-app_commit/src/test/java'...
          [TASKS] Skipping non-existent folder '/home/hudson/data/workspace/proj-app_commit/src/main/resources'...
          [TASKS] Skipping non-existent folder '/home/hudson/data/workspace/proj-app_commit/src/test/resources'...
          [HUDSON] Archiving /home/hudson/data/workspace/proj-app_commit/pom.xml to /home/hudson/data/jobs/proj-app_commit/modules/com.myco.myproj$proj-app/builds/2010-09-07_15-59-14/archive/com.myco.myproj/proj-app/0.0.1-1-SNAPSHOT/pom.xml
          [INFO] ------------------------------------------------------------------------
          [ERROR] BUILD FAILURE
          [INFO] ------------------------------------------------------------------------
          [INFO] Unable to commit files
          Provider message:
          The git-push command failed.
          Command output:
          To ssh://user@mygerritserver:29418/cms/proj/proj-app.git
          ! [rejected] master -> master (non-fast-forward)
          error: failed to push some refs to 'ssh://user@mygerritserver:29418/cms/proj/proj-app.git'
          To prevent you from losing history, non-fast-forward updates were rejected
          Merge the remote changes (e.g. 'git pull') before pushing again. See the
          'Note about fast-forwards' section of 'git push --help' for details.
          </pre>

          James Nord added a comment - Still not working, relavent sections are: <pre> Checkout:proj-app_commit / /home/hudson/data/workspace/proj-app_commit - hudson.remoting.Channel@1c17335:cabci-cf-rh5-x64-01 Using strategy: Default Last Built Revision: Revision ec90272fc4b0def86159148588e4f9d602b256dc (origin/master) Checkout:proj-app_commit / /home/hudson/data/workspace/proj-app_commit - hudson.remoting.LocalChannel@a90942 GitAPI created Fetching changes from the remote Git repository Fetching upstream changes from ssh://user@mygerritserver:29418/cms/proj/proj-app.git [proj-app_commit] $ git fetch -t ssh://user@mygerritserver:29418/cms/proj/proj-app.git +refs/heads/ :refs/remotes/origin/ [proj-app_commit] $ git ls-tree HEAD Seen branch in repository origin/master Commencing build of Revision ec90272fc4b0def86159148588e4f9d602b256dc (origin/master) GitAPI created Checking out Revision ec90272fc4b0def86159148588e4f9d602b256dc (origin/master) [proj-app_commit] $ git checkout -f ec90272fc4b0def86159148588e4f9d602b256dc [proj-app_commit] $ git tag -a -f -m "Hudson Build #36" hudson-proj-app_commit-36 Recording changes in branch origin/master [proj-app_commit] $ git whatchanged --no-abbrev -M --pretty=raw ec90272fc4b0def86159148588e4f9d602b256dc..ec90272fc4b0def86159148588e4f9d602b256dc Parsing POMs <snip> [INFO] Executing: /bin/sh -c cd /home/hudson/data/workspace/proj-app_commit && git add pom.xml proj-bp/pom.xml proj-bp/proj-bp-adiSupport/pom.xml proj-bp/proj-bp-content/pom.xml proj-bp/proj-bp-offer/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-base/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-interface/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-mercury/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-mock/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-xti/pom.xml proj-bp/proj-bp-publishing/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-base/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-interface/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-mercury/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-mock/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-xti/pom.xml proj-definitions/pom.xml proj-definitions/proj-definitions-commonSpring/pom.xml proj-definitions/proj-definitions-packWorkflow/pom.xml proj-definitions/proj-definitions-classificationWorkflow/pom.xml proj-definitions/proj-definitions-ingestWorkflow/pom.xml proj-platform/pom.xml proj-platform/proj-platform-dataEventNotifier/pom.xml proj-platform/proj-platform-workflowSupport/pom.xml proj-platform/proj-platform-status/pom.xml proj-externals/pom.xml proj-externals/proj-externals-gateway/pom.xml proj-platform/proj-platform-applicationHost/pom.xml proj-packaging/pom.xml [INFO] Working directory: /home/hudson/data/workspace/proj-app_commit [INFO] Executing: /bin/sh -c cd /home/hudson/data/workspace/proj-app_commit && git status [INFO] Working directory: /home/hudson/data/workspace/proj-app_commit [INFO] Executing: /bin/sh -c cd /home/hudson/data/workspace/proj-app_commit && git commit --verbose -F /tmp/maven-scm-1512028766.commit pom.xml proj-bp/pom.xml proj-bp/proj-bp-adiSupport/pom.xml proj-bp/proj-bp-content/pom.xml proj-bp/proj-bp-offer/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-base/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-interface/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-mercury/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-mock/pom.xml proj-bp/proj-bp-offer/proj-bp-offer-xti/pom.xml proj-bp/proj-bp-publishing/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-base/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-interface/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-mercury/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-mock/pom.xml proj-bp/proj-bp-publishing/proj-bp-publishing-xti/pom.xml proj-definitions/pom.xml proj-definitions/proj-definitions-commonSpring/pom.xml proj-definitions/proj-definitions-packWorkflow/pom.xml proj-definitions/proj-definitions-classificationWorkflow/pom.xml proj-definitions/proj-definitions-ingestWorkflow/pom.xml proj-platform/pom.xml proj-platform/proj-platform-dataEventNotifier/pom.xml proj-platform/proj-platform-workflowSupport/pom.xml proj-platform/proj-platform-status/pom.xml proj-externals/pom.xml proj-externals/proj-externals-gateway/pom.xml proj-platform/proj-platform-applicationHost/pom.xml proj-packaging/pom.xml [INFO] Working directory: /home/hudson/data/workspace/proj-app_commit [INFO] Executing: /bin/sh -c cd /home/hudson/data/workspace/proj-app_commit && git push [INFO] Working directory: /home/hudson/data/workspace/proj-app_commit [TASKS] Skipping non-existent folder '/home/hudson/data/workspace/proj-app_commit/src/main/java'... [TASKS] Skipping non-existent folder '/home/hudson/data/workspace/proj-app_commit/src/test/java'... [TASKS] Skipping non-existent folder '/home/hudson/data/workspace/proj-app_commit/src/main/resources'... [TASKS] Skipping non-existent folder '/home/hudson/data/workspace/proj-app_commit/src/test/resources'... [HUDSON] Archiving /home/hudson/data/workspace/proj-app_commit/pom.xml to /home/hudson/data/jobs/proj-app_commit/modules/com.myco.myproj$proj-app/builds/2010-09-07_15-59-14/archive/com.myco.myproj/proj-app/0.0.1-1-SNAPSHOT/pom.xml [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Unable to commit files Provider message: The git-push command failed. Command output: To ssh://user@mygerritserver:29418/cms/proj/proj-app.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'ssh://user@mygerritserver:29418/cms/proj/proj-app.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details. </pre>

          James Nord added a comment -

          This is working if you set the Git plugin setting to merge before build (whatever that does?)

          James Nord added a comment - This is working if you set the Git plugin setting to merge before build (whatever that does?)

          James Nord added a comment -

          no it's not as the modified poms don't get commited back in as we seem to be on a local branch.

          James Nord added a comment - no it's not as the modified poms don't get commited back in as we seem to be on a local branch.

          James Nord added a comment -

          This is working if I use the m2 extra steps plugin and the following config

          Git
          "Merge before build" origin, master

          And m2 extra steps (pre-build)
          git checkout master || git checkout -b master
          git reset --hard origin/master

          James Nord added a comment - This is working if I use the m2 extra steps plugin and the following config Git "Merge before build" origin, master And m2 extra steps (pre-build) git checkout master || git checkout -b master git reset --hard origin/master

          tfnico added a comment -

          I see the same thing. By default, the workspace is in (no branch).

          If I manually run

          mvn -X -B -f /[jenkins]/jobs/[job]/workspace/pom.xml -Dresume=false release:prepare release:perform
          

          .. it ends with a

          org.apache.maven.scm.ScmException: Detecting the current branch failed: fatal: ref HEAD is not a symbolic ref
          

          If I first do a 'git checkout master', and then repeat the command it works fine.

          Back in Jenkins, I then configured the job's - SCM section with Branch Specifier: "master", and under Advanced I entered Checkout/merge to local branch (optional): "master"

          After that it works fine. Still, it's a bit annoying that it didn't work by default. I don't know if this is the fault of the maven-release-plugin (should it be possible to make a release when not on a branch?).. but not having to configure this for each job would be nice.

          tfnico added a comment - I see the same thing. By default, the workspace is in (no branch). If I manually run mvn -X -B -f /[jenkins]/jobs/[job]/workspace/pom.xml -Dresume= false release:prepare release:perform .. it ends with a org.apache.maven.scm.ScmException: Detecting the current branch failed: fatal: ref HEAD is not a symbolic ref If I first do a 'git checkout master', and then repeat the command it works fine. Back in Jenkins, I then configured the job's - SCM section with Branch Specifier : "master", and under Advanced I entered Checkout/merge to local branch (optional) : "master" After that it works fine. Still, it's a bit annoying that it didn't work by default. I don't know if this is the fault of the maven-release-plugin (should it be possible to make a release when not on a branch?).. but not having to configure this for each job would be nice.

          Frédéric Camblor added a comment - - edited

          I'm facing the same issue as tfnico with 1.409.2 and git plugin 1.1.12

          Frédéric Camblor added a comment - - edited I'm facing the same issue as tfnico with 1.409.2 and git plugin 1.1.12

          git plugin does checkout commits by RefID, not branches. You can force it to use a local branch (advanced section) so that maven release process will be able to commit, tag and push to remote repository

          Nicolas De Loof added a comment - git plugin does checkout commits by RefID, not branches. You can force it to use a local branch (advanced section) so that maven release process will be able to commit, tag and push to remote repository

          Jan Klass added a comment -

          What is the reason behind that decision? Why does it not check out the branch?

          This is especially confusing as you already were branch-specific when specifying the branch specifier.
          When you specify the job shall build master, why does it not check out master?

          Jan Klass added a comment - What is the reason behind that decision? Why does it not check out the branch? This is especially confusing as you already were branch-specific when specifying the branch specifier. When you specify the job shall build master, why does it not check out master?

            ndeloof Nicolas De Loof
            sannies sannies
            Votes:
            14 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated:
              Resolved: