Skip to content

Pass coursier credentials to private repositories - #154

Merged
rochala merged 1 commit into
mainfrom
issue-artifactory
Aug 29, 2026
Merged

Pass coursier credentials to private repositories#154
rochala merged 1 commit into
mainfrom
issue-artifactory

Conversation

@rochala

@rochala rochala commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Problem

Artifacts hosted on a private Artifactory fail with 401 in cellar while sbt/Mill builds using the same ~/.config/coursier/credentials.properties work.

Causes (both in coursier-interface)

  1. interface:1.0.28 never reads credentials.properties / COURSIER_CREDENTIALScoursier/interface#460, fixed in 1.0.29-M4 (#473).
  2. Still on 1.0.29-M4: ApiHelper.fetch passes the credential-bearing cache to Resolve but builds Artifacts() with its default cache, so POMs authenticate and JAR downloads get 401. Reproduced by mimicking the construction with coursier core 2.1.25-M19; adding .withCache(cache0) fixes it (worth an upstream PR).

Fix

  • Bump io.get-coursier:interface → 1.0.29-M4.
  • New CoursierCredentials: reads COURSIER_CREDENTIALS (inline or file path) or credentials.properties from COURSIER_CONFIG_DIR / XDG_CONFIG_HOME / ~/.config/coursier / macOS dir, and attaches host-matched credentials to each --repository (honours https-only). Repository-level auth reaches the JAR request regardless of the cache bug.
  • README note on private repositories.
  • lib.test.testParallelism = false: one forked JVM per test class saturated all cores and tests failed under load.

Verification

  • Local Maven repo behind HTTP basic auth, artifact only there, credentials only in credentials.properties: before → JAR 401; after → POM and JAR 401→200, symbol rendered. Same with COURSIER_CREDENTIALS. With no credentials the error lists unauthorized: <url> (Artifactory Realm) under "Tried:".
  • ./mill __.test 623/623, ./mill __.fix --check clean.

Not yet confirmed against a real Artifactory — reporter should retry with this build.

🤖 Generated with Claude Code

Users with artifacts on a private Artifactory got 401s from cellar while
their sbt/Mill builds resolved fine. Two causes in coursier-interface:

- 1.0.28 never read ~/.config/coursier/credentials.properties or
  COURSIER_CREDENTIALS (coursier/interface#460). Fixed upstream in
  1.0.29-M4, so bump to it.
- Even on 1.0.29-M4, ApiHelper.fetch gives the credential-bearing cache
  only to Resolve; Artifacts() keeps its default cache, so POMs
  authenticate but JAR downloads still fail with 401.

Repository-level credentials travel with every artifact request, so read
the same sources coursier does and attach them to each --repository whose
host matches. Verified against a basic-auth Maven server: POM and JAR both
download with only credentials.properties present.

Also disable per-class test forking for lib.test: one JVM per test class,
each booting a tasty-query Context, saturated the machine and made tests
fail under load.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@rochala
rochala force-pushed the issue-artifactory branch from 1618af7 to dc41ee8 Compare August 29, 2026 11:31
@rochala
rochala merged commit f2d2a02 into main Aug 29, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant