Skip to content

Update Maven Central publication to new Sonatype Central Portal endpoints#3

Merged
mrdevrobot merged 3 commits intomainfrom
copilot/update-publish-endpoints
Jan 20, 2026
Merged

Update Maven Central publication to new Sonatype Central Portal endpoints#3
mrdevrobot merged 3 commits intomainfrom
copilot/update-publish-endpoints

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 20, 2026

CI/CD was failing with 401 errors because the publication configuration used legacy OSSRH Nexus endpoints (s01.oss.sonatype.org) while credentials were configured for the new Sonatype Central Portal (central.sonatype.com).

Changes

Updated scripts/publish-module.gradle.kts to use the new Sonatype Central Publishing API:

Before:

val releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)

After:

// New Sonatype Central Portal uses unified endpoint for both releases and snapshots
val repoUrl = "https://central.sonatype.com/api/v1/publisher/upload?publishingType=AUTOMATIC"
url = uri(repoUrl)

The new Central Portal uses a unified endpoint with publishingType=AUTOMATIC for both releases and snapshots, eliminating the conditional logic and duplicate URL variables.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.5-bin/5t9huq95ubn472n8rpzujfbqh/gradle-8.5/lib/gradle-launcher-8.5.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.5-bin/5t9huq95ubn472n8rpzujfbqh/gradle-8.5/lib/agents/gradle-instrumentation-agent-8.5.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.5 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Problem

The CI/CD workflow is failing during the publication step with 401 authentication errors when trying to publish to Maven Central:

Could not PUT 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/...'. 
Received status code 401 from server: Content access is protected by token

The issue occurs in the scripts/publish-module.gradle.kts file which is currently configured to use the legacy OSSRH Nexus endpoints (s01.oss.sonatype.org), but the user's credentials are configured for the new Sonatype Central Portal (central.sonatype.com).

Solution

Update the scripts/publish-module.gradle.kts file to use the new Sonatype Central Publishing API endpoints instead of the legacy OSSRH Nexus endpoints.

File to modify: scripts/publish-module.gradle.kts

At lines 51-52, replace the old URLs:

Current (OLD):

val releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"

New (UPDATED):

val releasesRepoUrl = "https://central.sonatype.com/api/v1/publisher/upload?publishingType=AUTOMATIC"
val snapshotsRepoUrl = "https://central.sonatype.com/api/v1/publisher/upload?publishingType=AUTOMATIC"

Additional Context

  • The credentials validation step passes successfully (secrets exist and are valid for central.sonatype.com)
  • The signing configuration is correct and doesn't need changes
  • The new Sonatype Central Portal uses a unified endpoint for both releases and snapshots with automatic publishing
  • The OSSRH_USERNAME and OSSRH_PASSWORD environment variables are correctly configured for the new system

This change will allow the workflow to successfully publish artifacts to Maven Central using the new infrastructure.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 20, 2026 09:24
Co-authored-by: mrdevrobot <12503462+mrdevrobot@users.noreply.github.com>
Co-authored-by: mrdevrobot <12503462+mrdevrobot@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Maven Central publication endpoints in Gradle script Update Maven Central publication to new Sonatype Central Portal endpoints Jan 20, 2026
Copilot AI requested a review from mrdevrobot January 20, 2026 09:27
@mrdevrobot mrdevrobot marked this pull request as ready for review January 20, 2026 09:28
@mrdevrobot mrdevrobot merged commit fcb3cdf into main Jan 20, 2026
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.

2 participants