I am using Maven Jib plugin to deploy my application to Gitlab docker registry. If I use docker login registry.gitlab.com
and enter username and password I can log in to the gitlab registry successfully. I can see that ~/.docker/config.json
contains the following information:
{
"auths": {
"https://registry.gitlab.com": {},
"registry.gitlab.com": {}
},
"HttpHeaders": {
"User-Agent": "Docker-Client/19.03.2 (darwin)"
},
"credsStore": "desktop",
"stackOrchestrator": "swarm"
}
Now if I try to run mvn -Djib.to.auth.username=${username} -Djib.to.auth.password=${password} compile jib:build
it fails with the 401 Unauthorized exception. The reason I need to pass the username and password is I would like to run this command in my CICD pipeline and it is required to pass the username and password somehow. I have tested other approaches like setting credentials in the .m2/settings.xml
or pom.xml
. None of them works.