arktekk / sbt-aether-deploy

Deploy SBT artifacts using Maven Artifact Resolver (formerly Eclipse Aether)
Other
84 stars 31 forks source link

deploy to azure artifacts #77

Open schragnasher opened 1 year ago

schragnasher commented 1 year ago

I am attempting to deploy to azure artifacts with aether deploy as an alternative to the sbt deployer. The sbt deploy does not seem to work. Has anyone had success with aetherDeploy and azure repo? I keep getting unauthorized 401 errors, but I know the credentials are correct as I can deploy a normal maven java project just fine.

yhvicey commented 1 year ago

Looks like when uploading jar file, plugin (or aether) will send an OPTIONS api call to https://pkgs.dev.azure.com/<org>/_packaging/<feed>/maven/v1/<pkg org>/<pkg name>/<pkg version>/<jar name> with credentials configured, which will return a 401 error. And after receiving this 401 error, the following PUT call will not carry credentials configured - this looks more like aether behavior, I checked the source code and seems the plugin simply forwards deploy requests to underlying aether binary. Maybe need to create another issue in Aether repo (not sure how to call it - aether deploy tool?)

yhvicey commented 1 year ago

Tried to use aetherCustomerHttpHeaders to force apply Basic auth for all requests but seems not working - @hamnis (sorry to ping you) Will Authorization header be ignored using this approach?

StigLau commented 1 year ago

Sounds like my problem of deploying to Gitlab Package Repo faces the same issue. However, I know that first of all, my configuration of sbt/aether plugin is incorrect. Can you provide an example of how the aether plugin configuration should look like? Specifically for setting AetherKeys/aetherCustomHttpHeaders.

This is the gitlab/maven .m2/settings.xml config doc, which works for me

hamnis commented 1 year ago

https://docs.gitlab.com/ee/user/packages/maven_repository/?tab=sbt

This should work with aether as well. This must be set for each project.

publishTo and credentials needs to be configured on the project

aetherCustomHttpHeaders needs to be set on each project.

def myConfigureProjects: (Project => Project) = _.settings(
  aetherCustomHttpHeaders := Map("Custom-header", "abc"),
  publishTo := Some("gitlab" at "https:://gitlab.com/foo"),
  credentials += credentials += Credentials("GitLab Packages Registry", "gitlab.com", "foo-deploy-token", "<token>")
)

lazy val p = project.configure(myConfigureProjects)

lazy val a = project.configure(myConfigureProjects)