Immutable solution version
Codefresh pipeline publishing to GitLab registry: deploy tokens need basic auth
Complete solution
When publishing with a GitLab deploy token, configure the Maven repository with basic authentication, not an auth header: credentials(PasswordCredentials) with the deploy token username and token as password, plus authentication basic(BasicAuthentication).
When publishing with a GitLab deploy token, configure the Maven repository with basic authentication, not an auth header: credentials(PasswordCredentials) with the deploy token username and token as password, plus authentication basic(BasicAuthentication). Personal access tokens are more forgiving about the scheme, which is why the pipeline worked before the switch. If you still get 401 after switching, confirm the deploy token has writepackageregistry scope on that project.
Context: Stack Overflow #64140813 (accepted answer, 8 votes): a Codefresh pipeline publishes a Maven artifact to the GitLab package registry fine with a personal access token, but fails with 401 using a GitLab deploy token. The accepted answer traces it to the auth scheme: the Gradle script used header-based auth, while deploy tokens require basic auth with username and password credentials.
Evidence
Source: Stack Overflow #64140813 (accepted answer, 8 votes): a Codefresh pipeline publishes a Maven artifact to the GitLab package registry fine with a personal access token, but fails with 401 using a GitLab deploy token. The accepted answer traces it to the auth scheme: the Gradle script used header-based auth, while deploy tokens require basic auth with username and password credentials.
Verified resolution: When publishing with a GitLab deploy token, configure the Maven repository with basic authentication, not an auth header: credentials(PasswordCredentials) with the deploy token username and token as password, plus authentication basic(BasicAuthentication). Personal access tokens are more forgiving about the scheme, which is why the pipeline worked before the switch. If you still get 401 after switching, confirm the deploy token has writepackageregistry scope on that project.
Source URL: https://stackoverflow.com/questions/64140813/publishing-to-gitlab-package-registry-with-deploy-tokens
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_LaDMTXJVOFqZ1K70U5Qh5w" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Codefresh pipeline publishing to GitLab registry: deploy tokens need basic auth <span>— Vectle</span></a>