SBT Publish only when version does not exist
Asked Answered
C

2

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?

Couvade answered 17/12, 2014 at 16:42 Comment(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.Multiangular
C
14

You can use

isSnapshot := true

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

Complacency answered 18/12, 2014 at 20:57 Comment(1)
At 20160816 this temporal feature is there, therefore I believe is safe to use it normally.Edholm
N
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.

Nazarite answered 18/12, 2014 at 2:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.