13

So I have a job in my CI app that publishes to Nexus when a change pushed to develop on an app.

Is there a way to make ./sbt publish idempotent? Because occasionally we want to run the job again because of a temporary issue, and it'll error out with:

[16:31:24]java.io.IOException: destination file exists and overwrite == false
[16:31:24]  at org.apache.ivy.plugins.repository.url.URLRepository.put(URLRepository.java:75)
[16:31:24]  at org.apache.ivy.plugins.repository.AbstractRepository.put(AbstractRepository.java:130)
[16:31:24]  at sbt.ConvertResolver$ChecksumFriendlyURLResolver$class.put(ConvertResolver.scala:78)
[16:31:24]  at sbt.ConvertResolver$PluginCapableResolver$1.put(ConvertResolver.scala:103)
[16:31:24]  at org.apache.ivy.plugins.resolver.RepositoryResolver.publish(RepositoryResolver.java:216)

Because we've not bumped the version number. Right now I'm going with a hacky:

./sbt publish || true

So the job doesnt exit 1 and error in CI. Is there a better way?

Peter Souter
  • 5,110
  • 1
  • 33
  • 62
  • 1
    IMHO, this would be a very elegant solution. I often find some bug with my SBT configuration when cross-compiling and need to publish the other version that was skipped. I don't want to bail out of publishing the artifact for Scala 2.11 just because 2.10 already exists. – Jeff May Aug 05 '15 at 18:08

2 Answers2

15

You can use

isSnapshot := true

This only allows a file to be overwritten. It seems likely that this behavior may change in the future.

Christopher Helck
  • 1,130
  • 2
  • 8
  • 23
0

You could either always ref the version as part of your build or query Nexus via the REST API to figure out if the version already exists prior to proceeding with a build.

Manfred Moser
  • 29,539
  • 13
  • 92
  • 123