Reputation: 4871
I'm trying to publish a project to an artifactory Maven repo but I'm getting the following error (409 conflict):
[error] (kamon-cloudwatch/*:publish) java.io.IOException: PUT operation to URL https://[org].artifactoryonline.com/[org]/libs-release-local/kamon-cloudwatch/kamon-cloudwatch_2.11/0.6.5-SNAPSHOT/kamon-cloudwatch_2.11-0.6.5-SNAPSHOT.pom failed with status code 409: Conflict
Here's the relevant portion from my build.sbt
publishTo := sys.env.get("BUILD_NUMBER")
.map(_ => Some("Artifactory Realm" at "https://[org].artifactoryonline.com/[org]/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime))
.getOrElse(Some("Artifactory Realm" at "https://[org].artifactoryonline.com/[org]/libs-release-local")),
credentials += Credentials(
"Artifactory Realm",
"[org].artifactoryonline.com",
sys.env.get("ARTIFACTORY_USER").getOrElse(""),
sys.env.get("ARTIFACTORY_KEY").getOrElse("")
)
Solutions which envolve modifying settings on the artifactory side are not an option since I am not an administrator for the repository.
(Also wouldn't mind a better solution for storing credentials)
Upvotes: 3
Views: 2457
Reputation: 4871
Turns out artifactory didn't like the -SNAPSHOT in my release version. Here's what I ended up doing:
version := "0.6.5" + sys.env.get("BUILD_NUMBER").map("." + _ + "-SNAPSHOT").getOrElse(""),
publishTo := {
if (isSnapshot.value) {
Some("Artifactory Realm" at "https://[org].artifactoryonline.com/[org]/libs-snapshot-local")
} else {
Some("Artifactory Realm" at "https://[org].artifactoryonline.com/[org]/libs-release-local")
}
},
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
My release build leaves $BUILD_NUMBER
empty so there's no build number or -SNAPSHOT
and so it works now.
And here's what the .credentials
file looks like:
realm=Artifactory Realm
host=[org].artifactoryonline.com
user=[user]
password=[api-key]
Upvotes: 1
Reputation: 146
Actually, this is a setting for Maven/SBT repositories in Artifactory that you can configure. Please try editing the repository by going to Admin->Repositories->Local and then clicking on the Maven repository you are trying to deploy to. Then, simply check the "Handle Snapshots" checkbox to enable Snapshots in that repository, or "Handle Releases" to allow releases, or both for no restrictions.
As a side note to your second comment, you can also configure the credentials directly into the build.sbt rather than setting environment variables as you have it, below is an example:
publishTo := Some("Artifactory Realm" at "http://localhost:8081/artifactory/") credentials += Credentials("Artifactory Realm", "localhost", "admin", "password")
Where admin is the user and password is the password. Note that this is a potential security risk storing plain text (or encrypted/api key for that matter) passwords in a file. However, this is up to you to decide the best way to manage security.
Upvotes: 2