'Authenticate to Azure Container Registry with spotify docker-maven-plugin

I try to push a docker image with docker-maven-plugin from spotify

Command:

mvn deploy

OR tried also

mvn clean package docker:push

My plugin config looks like:

<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>dockerfile-maven-plugin</artifactId>
    <version>${dockerfile-maven-plugin.version}</version>
    <configuration>
        <repository>${docker.image.prefix}/${project.artifactId}</repository>
        <tag>${docker.tag}</tag>
        <useMavenSettingsForAuth>true</useMavenSettingsForAuth>
        <googleContainerRegistryEnabled>false</googleContainerRegistryEnabled>
    </configuration>
</plugin>

Properties:

<properties>
    <java.version>11</java.version>
    <dockerfile-maven-plugin.version>1.4.13</dockerfile-maven-plugin.version>
    <docker.tag>latest</docker.tag>
    <docker.image.prefix>myacrName.azurecr.io</docker.image.prefix>
    <java.version>1.8</java.version>
</properties>

And my error log is:

[ERROR] unauthorized: authentication required, visit https://aka.ms/acr/authorization for more information.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  11.848 s
[INFO] Finished at: 2022-02-10T20:19:29+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.4.13:push (default-cli) on project myaccount-service: Could not push image: unauthorized: authentication required, visit https://aka.ms/acr/authorization for m
ore information. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Just to be sure I also added in settings.xml the car server like:

<servers>
    <server>
        <id>myacrName.azurecr.io</id>
        <username><SPN_ID></username>
        <password><SPN_PASSWORD></password>
    </server>
</servers>

I hope someone know a solution or can point me to a direction



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source