Search code examples
mavenartifactory

Artifactory mvn deploy not auhorized


I have installed artifactory-oss on a kubernetes cluster but I can't manage to deploy on it using maven.

When I run mvn deploy I have this error

.0-SNAPSHOT/maven-metadata.xml from/to snapshots (https://artifactory.adibox.be/artifactory/libs-snapshot-local): Not authorized -> [Help 1]
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>be.adibox</groupId>
    <artifactId>adiboxorm</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <modules>
        <module>annotations</module>
    </modules>

    <distributionManagement>
        <snapshotRepository>
            <id>snapshots</id>
            <name>artifactory-oss-artifactory-0-snapshots</name>
            <url>https://artifactory.adibox.be/artifactory/libs-snapshot-local</url>
        </snapshotRepository>
    </distributionManagement>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
    </dependencies>


</project>

And here is my settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <servers>
    <server>
      <username>${security.getCurrentUsername()}</username>
      <password>${security.getEscapedEncryptedPassword()!"<myencryptedpassword>"}</password>
      <id>central</id>
    </server>
    <server>
      <username>${security.getCurrentUsername()}</username>
      <password>${security.getEscapedEncryptedPassword()!"<myencryptedpassword>"}</password>
      <id>snapshots</id>
    </server>
  </servers>
  <mirrors>
    <mirror>
      <mirrorOf>*</mirrorOf>
      <name>libs-snapshot</name>
      <url>https://artifactory.adibox.be/artifactory/libs-snapshot</url>
      <id>libs-snapshot</id>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>https://artifactory.adibox.be/artifactory/libs-release</url>
        </repository>
        <repository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>https://artifactory.adibox.be/artifactory/libs-snapshot</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>https://artifactory.adibox.be/artifactory/libs-release</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>https://artifactory.adibox.be/artifactory/libs-snapshot</url>
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>

</settings>

At first the URL generated by artifactory was https://artifactory.adibox.be:80/artifactory/libs-snapshot but I was getting an SSL error. I removed the :80 and I result in the error specified above.

Any idea what could be wrong ? Is it because Artifactory is deployed on a Kubernetes cluster ?

I'm able to see the list of artifacts in the browser by going to https://artifactory.adibox.be/artifactory/libs-snapshot-local and entering my credentials.

Thanks.


Solution

  • I had a similar error with Nexus deployed on gcp.

    Comparing my settings with your settings, I think you need the mirror id. In my case : nexus-releases

    As you can see in my attached settings, <server> defines an user/password with an id <id>nexus-releases</id>.

    Then in mirror section, its has and id with the same value of server id: nexus-releases

    <settings>
      <pluginGroups></pluginGroups>
      <proxies></proxies>
      <servers>
        <server>
          <id>nexus-releases</id>
          <username>jane</username>
          <password>doe</password>
        </server>
      </servers>
      <mirrors>
        <mirror>
          <id>nexus-releases</id>
          <mirrorOf>*</mirrorOf>
          <name>central</name>
          <url>https://mynexus.com/repository/maven-public/</url>
        </mirror>
      </mirrors>
      <profiles></profiles>
    </settings>
    

    Finally at deploy, this id nexus-releases is required too:

    mvn deploy:deploy-file -DgeneratePom=false -DrepositoryId=nexus-releases -Durl=https://mynexus.com/repository/maven-releases/ -DpomFile=pom.xml -Dfile=myjar-1.0.0.jar
    

    Anyway if error continues, I advice you the steps to reproduce your issue. If you cannot reproduce the issue, you can not find a solution.

    • Try with localhost artifactory. Could be an error in kuberentes, gcp , aws , etc
    • Use an empty m2 repo and ensure that your seetinng.xml is used. You could that append this sentences to your mvn deploy command :
        -s /tmp/my_settings.xml -Dmaven.repo.local=/tmp/m2
    
    • Try to use linux instead windows.