Nexus credentials in Jenkins with sbt

眉间皱痕 提交于 2019-12-12 17:26:48

问题


I'm trying to make a nexus job to publish a jar to nexus. I'm using sbt with scala, and I have a configuration file with the required credentials in it. I'm having trouble when I run sbt publish, it's giving me unauthorized errors. I need to be able to link my credentials to my sbt build. I'm trying set the target of my configurations to ~/.ivy2/.credentials but it doesn't seem to be working. Does anyone have any advice on how to fix this?

Thanks.


回答1:


You can put all your credential files in a common directory, and add a global configuration file to add all of them in sbt.

~/.sbt/0.13/credentials.sbt

credentials ++= (Path.userHome / ".sbt" / "credentials")
  .listFiles
  .collect {
    case f if f.isFile => Credentials(f)
  }
  .toSeq

~/.sbt/credentials/my-nexus-repo

realm=Sonatype Nexus Repository Manager
host=mynexusrepo.com
user=username
password=password

~/.sbt/credentials/my-artifactory-repo

realm=Artifactory Realm
host=myartifactoryrepo.com
user=username
password=password



回答2:


Like in the sbt doc:

There are two ways to specify credentials for such a repository:

Inline

credentials += Credentials("Some Nexus Repository Manager", "my.artifact.repo.net", "admin", "password123")

External File

credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")

The credentials file is a properties file with keys realm, host, user, and password. For example:

realm=My Nexus Repository Manager
host=my.artifact.repo.net
user=admin
password=admin123


来源:https://stackoverflow.com/questions/35926694/nexus-credentials-in-jenkins-with-sbt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!