Skip to content

Commit c7debd6

Browse files
authored
Merge pull request scala#9658 from retronym/topic/credentials
Fix intermittent auth failure to artifactory from Jenkins
2 parents c7446af + a8ec10d commit c7debd6

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

build.sbt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ val fatalWarnings = settingKey[Boolean]("whether or not warnings should be fatal
5454
// enable fatal warnings automatically on CI
5555
Global / fatalWarnings := insideCI.value
5656

57+
Global / credentials ++= {
58+
val file = Path.userHome / ".credentials"
59+
if (file.exists && !file.isDirectory) List(Credentials(file))
60+
else Nil
61+
}
62+
5763
lazy val publishSettings : Seq[Setting[_]] = Seq(
58-
credentials ++= {
59-
val file = Path.userHome / ".credentials"
60-
if (file.exists && !file.isDirectory) List(Credentials(file))
61-
else Nil
62-
},
6364
// Add a "default" Ivy configuration because sbt expects the Scala distribution to have one:
6465
ivyConfigurations += Configuration.of("Default", "default", "Default", true, Vector(Configurations.Runtime), true),
6566
publishMavenStyle := true

project/ScriptCommands.scala

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,13 @@ object ScriptCommands {
107107
Global / baseVersionSuffix := "SPLIT",
108108
Global / resolvers += "scala-pr" at url,
109109
Global / publishTo := Some("sonatype-releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2"),
110-
Global / credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", env("SONA_USER"), env("SONA_PASS"))
110+
Global / credentials ++= {
111+
val user = env("SONA_USER")
112+
val pass = env("SONA_PASS")
113+
if (user != "" && pass != "")
114+
List(Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", user, pass))
115+
else Nil
116+
}
111117
// pgpSigningKey and pgpPassphrase are set externally by travis / the bootstrap script, as the sbt-pgp plugin is not enabled by default
112118
) ++ enableOptimizer
113119
}
@@ -168,7 +174,12 @@ object ScriptCommands {
168174

169175
Seq(
170176
Global / publishTo := Some("scala-pr-publish" at url2),
171-
Global / credentials += Credentials("Artifactory Realm", "scala-ci.typesafe.com", "scala-ci", env("PRIVATE_REPO_PASS"))
177+
Global / credentials ++= {
178+
val pass = env("PRIVATE_REPO_PASS")
179+
if (pass != "")
180+
List(Credentials("Artifactory Realm", "scala-ci.typesafe.com", "scala-ci", pass))
181+
else Nil
182+
}
172183
)
173184
}
174185

0 commit comments

Comments
 (0)