Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT credentials file with multiple realm

We run an artifactory server, that has moved to a different endpoint (artifactory-b.example.com). To make it backwards compatible, the old url (artifactory-a.example.com) is being proxied to the new one.

However, publishing with sbt uses a .ivy2/.credentials file with the following layout

realm=Artfactory realm
host=artifactory-a.example.com
user=artifactory-user
password=P4ssw0rdH4sh

however, I would like to change this so new builds will publish to the correct endpoint

realm=Artfactory realm
host=artifactory-d.example.com
user=artifactory-user
password=P4ssw0rdH4sh

Is it possible to add multiple realms in one file? That sbt will try the first, if it does not work (Forbidden|Not Found) the second? So that my .ivy2/.credentials file looks like

# old instance for backwards compatibility
realm=Artfactory realm
host=artifactory-a.example.com
user=artifactory-user
password=P4ssw0rdH4sh

# New spiffy instance
realm=Artfactory realm
host=artifactory-b.example.com 
user=artifactory-user
password=P4ssw0rdH4sh

Anyone any experience with this, or am I bound to using two files, and change the reference in my repo to the second file (i.e. .ivy2/.credentials2).

P.S. The realms are in a file, because multiple repos use these credentials to publish. So important here is that the realms have the same name, only a different endpoint (unlike this post):

like image 484
Rik Avatar asked Jul 18 '16 19:07

Rik


2 Answers

May there is no way to have multiple realms within a credential file, but you could have multiple realms within multiple credential files, each realm in a separate credential file.

In ~/.ivy/.credentials will be:

realm=Sonatype Nexus Repository Manager
host=mvn.nexus1.org
user=readonly
password=readonlyPass

And in ~/.ivy/.credentials.deploy will be:

realm=Sonatype Nexus Repository Manager
host=deploy.nexus2.org
user=deployment
password=deploymentPass

So then you will have these lines in your build.sbt:

credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials.deploy")
like image 143
youhans Avatar answered Nov 19 '22 22:11

youhans


Turns out that what I want is not possible using a properties file, because that is just not how property files work.

Maybe there is another way, but the solution I want can not be achieved in this way, unfortunately

like image 3
Rik Avatar answered Nov 20 '22 00:11

Rik