sbt-release icon indicating copy to clipboard operation
sbt-release copied to clipboard

unable to release from branch with symbolic remote

Open devmage opened this issue 11 years ago • 4 comments

I have a branch, release/0.1.1, from which I'm trying to run release with-defaults.

I run the following before doing so, so that it doesn't complain about a remote tracking branch: git branch --set-upstream release/0.1.1 origin/release/0.1.1

I receive the following error output and trace:

[info] Starting release process off commit: [removed by me]
[info] Checking remote [.] ...
[error] From .
[error]  * remote-tracking branch origin/release/0.1.1 -> FETCH_HEAD
java.lang.RuntimeException: Nonzero exit value: 128
    at scala.sys.package$.error(package.scala:27)
    at scala.Predef$.error(Predef.scala:142)
    at sbt.AbstractProcessBuilder.getString(ProcessImpl.scala:146)
    at sbt.AbstractProcessBuilder.$bang$bang(ProcessImpl.scala:149)
    at sbtrelease.Git$.isBehindRemote(Vcs.scala:104)
    at sbtrelease.ReleaseStateTransformations$$anonfun$checkUpstream$1.apply(ReleaseExtra.scala:195)
    at sbtrelease.ReleaseStateTransformations$$anonfun$checkUpstream$1.apply(ReleaseExtra.scala:181)
    at sbtrelease.ReleasePlugin$ReleaseKeys$$anonfun$2$$anonfun$apply$1.apply(ReleasePlugin.scala:49)
    at sbtrelease.ReleasePlugin$ReleaseKeys$$anonfun$2$$anonfun$apply$1.apply(ReleasePlugin.scala:49)
    at scala.collection.immutable.List.foreach(List.scala:318)
    at sbtrelease.ReleasePlugin$ReleaseKeys$$anonfun$2.apply(ReleasePlugin.scala:49)
    at sbtrelease.ReleasePlugin$ReleaseKeys$$anonfun$2.apply(ReleasePlugin.scala:33)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:60)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:60)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62)
    at sbt.Command$.process(Command.scala:95)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:100)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:100)
    at sbt.State$$anon$1.process(State.scala:179)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:100)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:100)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
    at sbt.MainLoop$.next(MainLoop.scala:100)
    at sbt.MainLoop$.run(MainLoop.scala:93)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:71)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:66)
    at sbt.Using.apply(Using.scala:25)
    at sbt.MainLoop$.runWithNewLog(MainLoop.scala:66)
    at sbt.MainLoop$.runAndClearLast(MainLoop.scala:49)
    at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:33)
    at sbt.MainLoop$.runLogged(MainLoop.scala:25)
    at sbt.StandardMain$.runManaged(Main.scala:57)
    at sbt.xMain.run(Main.scala:29)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
    at xsbt.boot.Launch$.run(Launch.scala:57)
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
    at xsbt.boot.Launch$.launch(Launch.scala:65)
    at xsbt.boot.Launch$.apply(Launch.scala:16)
    at xsbt.boot.Boot$.runImpl(Boot.scala:32)
    at xsbt.boot.Boot$.main(Boot.scala:21)
    at xsbt.boot.Boot.main(Boot.scala)
[error] Nonzero exit value: 128
[error] Use 'last' for the full log.

By contrast and with nearly the same configuration (changing the git branch line as needed, etc.), if I try to release with-defaults from a branch like master without slashes, execution proceeds normally.

About my env: I am running with Jenkins 1.549, sbt 0.13.1 (and so sbt-release 0.8), git 1.7.9.5, for a scala 2.10 project, inside an Ubuntu 12.04 instance.

devmage avatar Jan 31 '14 02:01 devmage

I think I figured out part of the problem: the isBehindRemote command doesn't seem to play well with symbolic tracking remotes.

https://github.com/sbt/sbt-release/blob/master/src/main/scala/Vcs.scala#L120

Compare the following configurations:

$ git symbolic-ref HEAD
refs/heads/release/0.1.1
$ git config branch.release/0.1.1.remote
.
$ git config branch.release/0.1.1.merge
refs/remotes/origin/release/0.1.1

This leads to an isBehindRemote construction like:

currentBranch = "release/0.1.1"
trackingRemote = "."
trackingBranch = "origin/release/0.1.1"
"rev-list", "%s..%s/%s".format(currentBranch, trackingRemote, trackingBranch)

--> git rev-list release/0.1.1.../origin/release/0.1.1

This, when executed, leads to the following output:

$ git rev-list release/0.1.1.../origin/release/0.1.1
fatal: ambiguous argument 'release/0.1.1.../origin/release/0.1.1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions

And that seems to be what's triggering the exception in my trace. Compare that to a non-symbolic construction:

% git symbolic-ref HEAD
refs/heads/release/0.1.1
% git config branch.release/0.1.1.remote
origin
% git config branch.release/0.1.1.merge
refs/heads/release/0.1.1

currentBranch = "release/0.1.1"
trackingRemote = "origin"
trackingBranch = "release/0.1.1"
"rev-list", "%s..%s/%s".format(currentBranch, trackingRemote, trackingBranch)

--> git rev-list release/0.1.1..origin/release/0.1.1

And, since my local is up to date with origin, that returns empty, which is the expected output.

The period also seems to throw off the construction when I remove the "origin/" in the trackingBranch string:

% git rev-list release/0.1.1.../release/0.1.1
fatal: ambiguous argument 'release/0.1.1.../release/0.1.1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

So, perhaps this issue is more about symbolic tracking remotes than it is about slashes. Is this a known behavior?

devmage avatar Jan 31 '14 20:01 devmage

I found that a workaround was to specify the "correct" branch refs in my Jenkins config as a pre-build script, as such:

git config branch.release/0.1.1.remote origin
git config branch.release/0.1.1.merge refs/heads/release/0.1.1

After that, release with-defaults executed successfully.

devmage avatar Jan 31 '14 21:01 devmage

We do this:

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

  git config branch.${TRAVIS_BRANCH}.remote origin
  git config branch.${TRAVIS_BRANCH}.merge refs/heads/${TRAVIS_BRANCH}

  echo "Publishing new version to Bintray"
  sbt "release with-defaults"

However it doesn't seem to help at all.

fatal: ref HEAD is not a symbolic ref
java.lang.RuntimeException: Nonzero exit value: 128
	at scala.sys.package$.error(package.scala:27)
	at sbt.AbstractProcessBuilder.getString(ProcessImpl.scala:134)
	at sbt.AbstractProcessBuilder.$bang$bang(ProcessImpl.scala:136)
	at sbtrelease.Git.currentBranch(Vcs.scala:135)
	at sbtrelease.Git.trackingRemoteCmd$lzycompute(Vcs.scala:130)
	at sbtrelease.Git.trackingRemoteCmd(Vcs.scala:130)
	at sbtrelease.Git.hasUpstream(Vcs.scala:133)
	at sbtrelease.ReleaseStateTransformations$$anonfun$check

Is there additional configuration required?

Regards.

alexflav23 avatar Jul 28 '17 10:07 alexflav23

I fixed that issue with putting the following into execute shell before sbt runs:

git checkout -f master

That should solve your problem temporarily, but with-default is simply not working. This is very critical and I think they should prioritize that issue. As this is breaking everyone who wants to use it automated release.

edit: with-default works but you would have to run in the following way:

sbt "release with-defaults"

helenzBV avatar Aug 01 '18 02:08 helenzBV