So I got a self-hosted instance of drone running on my server alongside a nexus3 repository. Now I have a java project that should be built, tested and then deployed into the repository every push, which works fine until we get to the deployment part. I found the plugin on the official site for plugins, Maven Auth which is supposed to create a settings.xml based on the configuration, that works (made my pipeline output the contents of the file via cat and showed a valid settings.xml file). The next step is configured to run
mvn deploy -B -s settings.xml
For some reason, maven doesn't use the username and password provided in the settings.xml (the server always returns an Unauthorized 401 error)
Entire .drone.yml:
kind: pipeline
name: default
type: docker
steps:
- name: compile
image: maven:3-jdk-8
commands:
- mvn compile -B -U
when:
event:
- push
- name: test
image: maven:3-jdk-8
commands:
- mvn test -B
when:
event:
- push
- name: authenticate
image: robertstettner/drone-mvn-auth
settings:
servers:
- id: some-id (same in pom.xml distribution repos)
username: username
password:
from_secret: repo_password
- name: deploy_repo
image: maven:3-jdk-8
commands:
- mvn deploy -B -gs settings.xml
when:
event:
- push
Some advice why this doesn't work would be dope! Thanks in advance!
Edit 2: So I investigated further and installed mitmproxy on my server to analyze the traffic (Client -> Nginx SSL termination proxy -> mitmproxy -> running nexus).
To authorize apparently maven uses a header called "Authorization". And the content is "Basic " + username:password encoded in base64.
Turns out, the content of the Authorization header from the request the drone instance issues is malformed. Decoded it looks like this:
Authorization: Basic USERNAME:[object Object]
instead of
Authorization: Basic USERNAME:password
I am going to try getting around the
password:
from_secret: repo_password
and hope the settings.xml file is the generated properly