Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonatype repository change since February 2021 #214

Closed
djice opened this issue Mar 3, 2021 · 19 comments
Closed

Sonatype repository change since February 2021 #214

djice opened this issue Mar 3, 2021 · 19 comments

Comments

@djice
Copy link

djice commented Mar 3, 2021

Hi,

I've just created a new component and I want to push it on sonatype using your plugin.

I have an issue in github action for task "run sbt ci-release"

[error] java.io.IOException: Server returned HTTP response code: 403 for URL: https://oss.sonatype.org/content/repositories/snapshots/io/github/***/core_2.11/1.0.0-SNAPSHOT/core_2.11-1.0.0-SNAPSHOT.pom

The url used to push the snapshot is https://oss.sonatype.org When I read the official documentation of sonatype https://central.sonatype.org/pages/releasing-the-deployment.html it seems that since feburary the server to used is not "oss.sonatype.org" but "s01.oss.sonatype.org"

Note: As of February 2021, all new projects began being provisioned on https://s01.oss.sonatype.org/. If your project is not provisioned on https://s01.oss.sonatype.org/, please login to the legacy host https://oss.sonatype.org/.

Is there a way to overwrite the sonatype server url ?

Thanks

@xerial
Copy link
Owner

xerial commented Mar 3, 2021

Publishing to oss.sonatype.org both for releases and snapshots repositories has been working well even in March 2021. I think the reason of the error would be different. Or this change might have been applied only to newly registered sonatype users.

If necessary, you can overwrite sonatypeRepository setting to point to a different repository.

@djice
Copy link
Author

djice commented Mar 4, 2021

Hi,

yes new users do not have rights on oss.sonatype.org

In my build.sbt I add
sonatypeRepository := "https://s01.oss.sonatype.org/service/local" sonatypeCredentialHost:= "s01.oss.sonatype.org"

But I already have the same issue
[error] java.io.IOException: Server returned HTTP response code: 403 for URL: https://oss.sonatype.org/content/repositories/snapshots/core/core_2.11/1.0.0-SNAPSHOT/core_2.11-1.0.0-SNAPSHOT.pom [error] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

@jorlina
Copy link

jorlina commented Mar 4, 2021

The 403 error is because the groupId in your POM does not match the groupId you were granted permissions for on s01.oss.sonatype.org. The error text implies that your groupId is simply core, and that doesn't look like any groupId that you'd be allowed to publish under, so the 403 is expected.

@djice
Copy link
Author

djice commented Mar 4, 2021

Hi,

now I have right on oss.sonatype.org and it works like a charm.

thanks

@steinybot
Copy link
Contributor

I can't get this to work.

I struggled for a long time trying to set sonatypeRepository and sonatypeCredentialHost in different scopes only to discover that it has to be on the root project.

Even after doing that it still fails with:

2021-03-06 07:37:22.631Z  info [SonatypeService] sonatypeRepository  : https://s01.oss.sonatype.org/service/local  - (SonatypeService.scala:23)
2021-03-06 07:37:22.635Z  info [SonatypeService] sonatypeProfileName : nz.co.bottech  - (SonatypeService.scala:24)
[info] Preparing a new staging repository for [sbt-sonatype] scala2plantuml 0.1.9
2021-03-06 07:37:22.636Z  info [SonatypeClient] Reading staging repository profiles...  - (SonatypeClient.scala:108)
2021-03-06 07:37:23.870Z  info [SonatypeClient] Reading staging profiles...  - (SonatypeClient.scala:120)
2021-03-06 07:37:23.957Z  info [SonatypeService] No previous staging repository for [sbt-sonatype] scala2plantuml 0.1.9 was found  - (SonatypeService.scala:96)
2021-03-06 07:37:23.964Z  info [SonatypeClient] Creating a staging repository in profile nz.co.bottech with a description key: [sbt-sonatype] scala2plantuml 0.1.9  - (SonatypeClient.scala:126)
2021-03-06 07:37:24.427Z  info [SonatypeClient] Created successfully: nzcobottech-1001  - (SonatypeClient.scala:139)
2021-03-06 07:37:24.519Z  info [SonatypeClient] Uploading bundle /home/runner/work/scala2plantuml/scala2plantuml/target/sonatype-staging/0.1.9 to https://oss.sonatype.org/service/local/staging/deployByRepositoryId/nzcobottech-1001/  - (SonatypeClient.scala:288)
2021-03-06 07:37:24.802Z error [Sonatype] 
java.io.IOException: Failure:java.util.concurrent.ExecutionException: java.io.IOException: Unexpected server response: 401 Unauthorized
	at org.sonatype.spice.zapper.internal.transport.AbstractChargerClient.doUpload(AbstractChargerClient.java:65)
	at org.sonatype.spice.zapper.internal.transport.AbstractClient.upload(AbstractClient.java:104)
	at org.sonatype.spice.zapper.internal.transport.AbstractClient.upload(AbstractClient.java:61)
	at xerial.sbt.sonatype.SonatypeClient.$anonfun$uploadBundle$1(SonatypeClient.scala:289)

I've just spent ages trying to track this down and debug it which is not that easy considering I need to replicate my CI environment to get the commands to do the right things and I discovered that despite there being these URL settings the deploy URL is hard coded in xerial.sbt.sonatype.SonatypeClient.StagingRepositoryProfile#deployUrl.

@xerial
Copy link
Owner

xerial commented Mar 11, 2021

sbt-sonatype 3.9.6 has been released so that we can switch the target just with sonatypeCredentialHost := "s01.oss.sonatype.org" setting. Thanks @steinybot for the PR!

@xerial xerial closed this as completed Mar 11, 2021
@larousso
Copy link

Hi, I still have an issue :

java.io.IOException: Server returned HTTP response code: 403 for URL: https://oss.sonatype.org/content/repositories/snapshots/...

Am I alone ?

@xerial
Copy link
Owner

xerial commented Mar 11, 2021

@larousso Are you setting sonatypeCredentialHost := "s01.oss.sonatype.org" with sbt-sonatype 3.9.6?

@larousso
Copy link

Yes I am

ThisBuild / sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org"
publishTo := sonatypePublishToBundle.value

I've tried only with

ThisBuild / sonatypeRepository := "https://s01.oss.sonatype.org/service/local"

But same result.

At the moment, I've tried sbt publishSigned for a snapshot version

@xerial
Copy link
Owner

xerial commented Mar 11, 2021

I've just found publishing to snapshot repo still points to the legacy repository. ok. I'll add a fix

@steinybot
Copy link
Contributor

@xerial what are the symptoms of that? I was trying to do snapshot releases and were getting a "too many redirects" error. From the logs it wasn't obvious that it was using the wrong URL.

@xerial
Copy link
Owner

xerial commented Mar 11, 2021

sonatypeSnapshot resolver, which is pre-defined in sbt, uses oss.sonatype.org. We need to be able to configure it as well:

Some(Opts.resolver.sonatypeSnapshots)

Publishing to snapshot repositories is managed by sbt, not by sbt-sonatype. If publishTo is properly configured to use s01 repo in sonatypePublishToBundle setting, I think it would work as expected.

@xerial xerial reopened this Mar 11, 2021
@xerial
Copy link
Owner

xerial commented Mar 11, 2021

@larousso @steinybot Just created a snapshot version #220 that probably fixes this issue https://oss.sonatype.org/content/repositories/snapshots/org/xerial/sbt/sbt-sonatype_2.12_1.0/3.9.7-SNAPSHOT/

Could you try it to confirm whether it fixes the issue?

@dieproht
Copy link

@larousso @steinybot Just created a snapshot version #220 that probably fixes this issue https://oss.sonatype.org/content/repositories/snapshots/org/xerial/sbt/sbt-sonatype_2.12_1.0/3.9.7-SNAPSHOT/

Could you try it to confirm whether it fixes the issue?

It works! I was able to publish a snapshot version of my multi-project to the new Sonatype repo with 3.9.7-SNAPSHOT. Thank you all!!

@larousso
Copy link

Hi, it works fine for both snapshot and release! Thanks

@xerial
Copy link
Owner

xerial commented Mar 12, 2021

Great! ok. I'll release this version as 3.9.7.

@xerial xerial closed this as completed in 2c04d40 Mar 12, 2021
@xerial
Copy link
Owner

xerial commented Mar 12, 2021

Published sbt-sonatype 3.9.7

@sideeffffect
Copy link

I'm using sbt-sonatype 3.9.7 with

  sonatypeCredentialHost := "s01.oss.sonatype.org",
  sonatypeRepository := "https://s01.oss.sonatype.org/service/local",

It still isn't working, I can't get SNAPSHOT published, I'm getting

java.net.ProtocolException: Server redirected too many  times (20)

What am I doing wrong?

@sideeffffect
Copy link

What am I doing wrong?

You, idiot, have been using token credentials from oss.sonatype.org (the old host) the whole time. You are supposed to use token credentials from s01.oss.sonatype.org (the new host).

mpollmeier added a commit to ShiftLeftSecurity/sbt-ci-release-early that referenced this issue Jul 8, 2021
mpollmeier added a commit to ShiftLeftSecurity/sbt-ci-release-early that referenced this issue Jul 8, 2021
* upgrade sbt-sonatype to 3.9.7 to support s01.oss.sonatype.org

re xerial/sbt-sonatype#214

* add legacy host warning re s01.oss.sonatype.org

* only one extra setting needed, apparently
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

No branches or pull requests

7 participants