Fix intermittent auth failure to artifactory from Jenkins #9658
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In 41e376a, the build was updated to support publishing from
Travis CI.
However, on Jenkins, the old means of supplying the publish
credentials to pr-validation snapshots was retained, it has
a ~/.credentials file. So we provided two credentials for the
same host/realm to SBT, and on Jenkins the DirectCredentials
contains an empty password.
Which one of these would SBT pick?
The
ivySbt
task in SBT registers the credentials in order in a global mapin Ivy (
CredentialStore
). So on Jenkins, the invalidDirectCredentials
would be overwritten in the map by he
FileCredentials
.But the fact that this is global state in Ivy appears to be a source of cross
talk between the configured credentials for different modules in the build.
Even though the publish task is serialized through the ivy lock, this lock
does not enclose the previous execution of the
ivySbt
which sets up thecredentials in
CredentialStore
.In our build, notice that the root project does not have the
FileCredentials
set. So if theivySBT
task for this project runs last,the global map will have the incorrect
DirectCredentials
.The fix in our build is easy, avoid configuring the
DirectCredentials
if theenvironment variables are absent. We can also standardize on using
Global/credentials :=
.The principled fix in SBT would be to thread the credentials down to the HTTP
client without using global state. It could also emit a warning if conflicting
credentials are configured for a given host/realm.