Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pushing to Git from Travis fails: fatal: ref HEAD is not a symbolic ref #210

Open
alexflav23 opened this issue Aug 23, 2017 · 12 comments
Open

Comments

@alexflav23
Copy link

alexflav23 commented Aug 23, 2017

  git branch --set-upstream ${TRAVIS_BRANCH} origin/${TRAVIS_BRANCH}

  git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
  git config branch.${TRAVIS_BRANCH}.remote origin
  git config branch.${TRAVIS_BRANCH}.merge refs/heads/${TRAVIS_BRANCH}

  git fetch --unshallow origin/${TRAVIS_BRANCH}

Have also tried:

install:
  - git fetch --unshallow --tags

Have tried all of the above, and yet to no avail.

Is there a way to do this properly? All the web trivia found is largely represented above but it doesn't seem to work.

@xuwei-k
Copy link
Member

xuwei-k commented Aug 24, 2017

Is this sbt-release plugin issue?

@alexflav23
Copy link
Author

@xuwei-k Pushing to git otherwise works perfectly in builds that do not use sbt-release it's only something in this plugin that seems to trigger the problem. I can successfully git push, however the pushCommit stage in this plugin fails.

@julianovidal
Copy link

julianovidal commented Sep 18, 2017

Same here.
I am running the build using a docker image on Gitlab CI Runner.
$ sbt release with-defaults
Does it has anything to do with credentials?

[info] Set current project to alderaan (in build file:/builds/juliano.vidal/alderaan/)
[info] Starting release process off commit: 3f65b88c05e625e4ee8193d8e0acc804f04d0982
fatal: ref HEAD is not a symbolic ref
java.lang.RuntimeException: Nonzero exit value: 128
	at scala.sys.package$.error(package.scala:27)
	at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:131)
	at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:101)
	at sbtrelease.Git.currentBranch(Vcs.scala:138)
	at sbtrelease.Git.trackingRemoteCmd$lzycompute(Vcs.scala:133)
	at sbtrelease.Git.trackingRemoteCmd(Vcs.scala:133)
	at sbtrelease.Git.hasUpstream(Vcs.scala:136)
	at sbtrelease.ReleaseStateTransformations$$anonfun$checkUpstream$1.apply(ReleaseExtra.scala:215)
	at sbtrelease.ReleaseStateTransformations$$anonfun$checkUpstream$1.apply(ReleaseExtra.scala:214)
	at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$5$$anonfun$apply$4.apply(ReleasePlugin.scala:193)
	at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$5$$anonfun$apply$4.apply(ReleasePlugin.scala:193)
	at scala.collection.immutable.List.foreach(List.scala:318)
	at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$5.apply(ReleasePlugin.scala:193)
	at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$5.apply(ReleasePlugin.scala:157)
	at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
	at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
	at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
	at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
	at sbt.Command$.process(Command.scala:93)
	at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
	at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
	at sbt.State$$anon$1.doX$1(State.scala:183)
	at sbt.State$$anon$1.process(State.scala:190)
	at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
	at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
	at sbt.MainLoop$.next(MainLoop.scala:96)
	at sbt.MainLoop$.run(MainLoop.scala:89)
	at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:68)
	at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:63)
	at sbt.Using.apply(Using.scala:24)
	at sbt.MainLoop$.runWithNewLog(MainLoop.scala:63)
	at sbt.MainLoop$.runAndClearLast(MainLoop.scala:46)
	at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:30)
	at sbt.MainLoop$.runLogged(MainLoop.scala:22)
	at sbt.StandardMain$.runManaged(Main.scala:109)
	at sbt.xMain.run(Main.scala:38)
	at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
	at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
	at xsbt.boot.Launch$.run(Launch.scala:109)
	at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
	at xsbt.boot.Launch$.launch(Launch.scala:117)
	at xsbt.boot.Launch$.apply(Launch.scala:18)
	at xsbt.boot.Boot$.runImpl(Boot.scala:41)
	at xsbt.boot.Boot$.main(Boot.scala:17)
	at xsbt.boot.Boot.main(Boot.scala)
[error] Nonzero exit value: 128
[error] Use 'last' for the full log.

@shklarsky
Copy link

shklarsky commented Oct 10, 2017

I am getting the same error while trying to use sbt-release in a Jenkins job.
It works okay locally but when running "release with-defaults" in Jenkins I get:

fatal: ref HEAD is not a symbolic ref
java.lang.RuntimeException: Nonzero exit value: 128
at scala.sys.package$.error(package.scala:27)
at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:131)
at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:101)
at sbtrelease.Git.currentBranch(Vcs.scala:138)
at sbtrelease.Git.trackingRemoteCmd$lzycompute(Vcs.scala:133)
at sbtrelease.Git.trackingRemoteCmd(Vcs.scala:133)
at sbtrelease.Git.hasUpstream(Vcs.scala:136)
at sbtrelease.ReleaseStateTransformations$$anonfun$checkUpstream$1.apply(ReleaseExtra.scala:215)
at sbtrelease.ReleaseStateTransformations$$anonfun$checkUpstream$1.apply(ReleaseExtra.scala:214)
at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$5$$anonfun$apply$4.apply(ReleasePlugin.scala:193)
at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$5$$anonfun$apply$4.apply(ReleasePlugin.scala:193)
at scala.collection.immutable.List.foreach(List.scala:318)
at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$5.apply(ReleasePlugin.scala:193)
at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$5.apply(ReleasePlugin.scala:157)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
at sbt.Command$.process(Command.scala:93)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
at sbt.State$$anon$1.doX$1(State.scala:183)
at sbt.State$$anon$1.process(State.scala:190)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.MainLoop$.next(MainLoop.scala:96)
at sbt.MainLoop$.run(MainLoop.scala:89)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:68)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:63)
at sbt.Using.apply(Using.scala:24)
at sbt.MainLoop$.runWithNewLog(MainLoop.scala:63)
at sbt.MainLoop$.runAndClearLast(MainLoop.scala:46)
at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:30)
at sbt.MainLoop$.runLogged(MainLoop.scala:22)
at sbt.StandardMain$.runManaged(Main.scala:109)
at sbt.xMain.run(Main.scala:38)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:41)
at xsbt.boot.Boot$.main(Boot.scala:17)
at xsbt.boot.Boot.main(Boot.scala)
[error] Nonzero exit value: 128

@SrikanthTati
Copy link

Same error while running "release with-defaults" in travis-ci. I'm using sbt 0.13.15, sbt-release 1.0.6.
Anyone managed to find a fix?

[info] Starting release process off commit: 57d2b83083824621b4b7e95b51fe4449fbf132c5
fatal: ref HEAD is not a symbolic ref
java.lang.RuntimeException: Nonzero exit value: 128
	at scala.sys.package$.error(package.scala:27)
	at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.slurp(ProcessBuilderImpl.scala:131)
	at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:101)
	at sbtrelease.Git.currentBranch(Vcs.scala:138)
	at sbtrelease.Git.trackingRemoteCmd$lzycompute(Vcs.scala:133)
	at sbtrelease.Git.trackingRemoteCmd(Vcs.scala:133)
	at sbtrelease.Git.hasUpstream(Vcs.scala:136)
	at sbtrelease.ReleaseStateTransformations$$anonfun$checkUpstream$1.apply(ReleaseExtra.scala:215)
	at sbtrelease.ReleaseStateTransformations$$anonfun$checkUpstream$1.apply(ReleaseExtra.scala:214)
	at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$5$$anonfun$apply$4.apply(ReleasePlugin.scala:193)
	at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$5$$anonfun$apply$4.apply(ReleasePlugin.scala:193)
	at scala.collection.immutable.List.foreach(List.scala:318)
	at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$5.apply(ReleasePlugin.scala:193)
	at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$$anonfun$5.apply(ReleasePlugin.scala:157)
	at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
	at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
	at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
	at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
	at sbt.Command$.process(Command.scala:93)
	at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
	at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
	at sbt.State$$anon$1.doX$1(State.scala:183)
	at sbt.State$$anon$1.process(State.scala:190)
	at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
	at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
	at sbt.MainLoop$.next(MainLoop.scala:96)
	at sbt.MainLoop$.run(MainLoop.scala:89)
	at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:68)
	at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:63)
	at sbt.Using.apply(Using.scala:24)
	at sbt.MainLoop$.runWithNewLog(MainLoop.scala:63)
	at sbt.MainLoop$.runAndClearLast(MainLoop.scala:46)
	at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:30)
	at sbt.MainLoop$.runLogged(MainLoop.scala:22)
	at sbt.StandardMain$.runManaged(Main.scala:109)
	at sbt.xMain.run(Main.scala:38)
	at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
	at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
	at xsbt.boot.Launch$.run(Launch.scala:109)
	at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
	at xsbt.boot.Launch$.launch(Launch.scala:117)
	at xsbt.boot.Launch$.apply(Launch.scala:18)
	at xsbt.boot.Boot$.runImpl(Boot.scala:41)
	at xsbt.boot.Boot$.main(Boot.scala:17)
	at xsbt.boot.Boot.main(Boot.scala)
[error] Nonzero exit value: 128
[error] Use 'last' for the full log.

@shklarsky
Copy link

I have managed to fix this issue.
"release with-defaults" attempts to push changes to version.sbt to the current branch (in my case the master).
When Jenkins performs git clone of a repository it is detached from the head.
I Just performed git checkout master before running "release with-defaults" and it fixed the issue

@alexflav23
Copy link
Author

@shklarsky @SrikanthTati @julianovidal

I have this in Travis and I call it as part of the setup, and it seems to work. I don't pretend to understand the fine print just yet, or why this doesn't work inspite of you forcing non shallow git cloning, but there you go.

#!/usr/bin/env bash
function fix_git {
    echo "Fixing git setup for $TRAVIS_BRANCH"
    git checkout ${TRAVIS_BRANCH}
    git branch -u origin/${TRAVIS_BRANCH}
    git config branch.${TRAVIS_BRANCH}.remote origin
    git config branch.${TRAVIS_BRANCH}.merge refs/heads/${TRAVIS_BRANCH}
}

@smartiniOnGitHub
Copy link

Hi all, we have the same problem in latest Jenkins, due to the way it gets sources from git repos.
FYI as a workaround we solved by forcing a checkout in a similar way shown here.

@lukaszlenart
Copy link

I tried the same solution as above and from this issue #60 but now I'm getting:

[info] Starting release process off commit: 1a76e7d4c92ba30ac7a557c87336c22bb2494c96
[info] Checking remote [origin] ...
[info] ERROR: Repository not found.
[info] fatal: Could not read from remote repository.
[info] Please make sure you have the correct access rights
[info] and the repository exists.
Error while checking remote. Still continue (y/n)? [n] [error] java.lang.RuntimeException: Aborting the release!

any ideas?

@abhijeet3112
Copy link

abhijeet3112 commented Feb 3, 2020

Earlier I was getting this error, fatal: ref HEAD is not a symbolic ref . After proceeding as per the mentioned solutions, I am getting error as
[0m[�[0m�[0minfo�[0m] �[0m�[0m fatal: unable to fork�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0mjava.lang.RuntimeException: Aborting the release!�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at scala.sys.package$.error(package.scala:26)�[0m
� [0m[�[0m�[31merror�[0m] �[0m�[0m at sbtrelease.ReleaseStateTransformations$.$anonfun$checkUpstream$1(ReleaseExtra.scala:230)�[0m
� [0m[�[0m�[31merror�[0m] �[0m�[0m at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$.$anonfun$releaseCommand$10(ReleasePlugin.scala:199)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at scala.collection.immutable.List.foreach(List.scala:388)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbtrelease.ReleasePlugin$autoImport$ReleaseKeys$.$anonfun$releaseCommand$2(ReleasePlugin.scala:199)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.Command$.$anonfun$applyEffect$4(Command.scala:142)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.Command$.$anonfun$applyEffect$2(Command.scala:137)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.Command$.process(Command.scala:181)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.MainLoop$.processCommand(MainLoop.scala:151)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:139)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.State$$anon$1.runCmd$1(State.scala:246)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.State$$anon$1.process(State.scala:250)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:139)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.MainLoop$.next(MainLoop.scala:139)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.MainLoop$.run(MainLoop.scala:132)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:110)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.io.Using.apply(Using.scala:22)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.MainLoop$.runWithNewLog(MainLoop.scala:104)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.MainLoop$.runAndClearLast(MainLoop.scala:59)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:44)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.MainLoop$.runLogged(MainLoop.scala:35)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.StandardMain$.runManaged(Main.scala:138)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at sbt.xMain.run(Main.scala:89)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at xsbt.boot.Launch$.run(Launch.scala:109)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at xsbt.boot.Launch$.launch(Launch.scala:117)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at xsbt.boot.Launch$.apply(Launch.scala:18)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at xsbt.boot.Boot$.runImpl(Boot.scala:56)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at xsbt.boot.Boot$.main(Boot.scala:18)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0m at xsbt.boot.Boot.main(Boot.scala)�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0mAborting the release!�[0m
�[0m[�[0m�[31merror�[0m] �[0m�[0mUse 'last' for the full log.�[0m

Any Idea about how to resolve this?

@ScalaWilliam
Copy link

Travis checks out the specific commit for some reason, rather than the branch name - so for example if you're using master branch to release, add git checkout master && in front of the SBT command.

@ianpojman
Copy link

It would be great if this could be added as an option to the plugin, if it makes sense. (to force checkout of master)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants