Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-12041

Maven build fails with empty local repository to "Not Authorized"

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • maven-plugin
    • Windows server, jenkins.war under tomcat, maven2 and maven3

      We have Artifactory behind apache httpd (that requires authentication).

      When I try to build a maven project against an empty local repository, I get the stack trace that will be below. This happens both with maven2 and maven3. Also on a different maven project, that depends on a release version parent, this also happens. On the web-server log I can that Jenkins contacts the server, gets 401 -Authorization Required and does not even try to authorize.

      The maven project builds successfully in shell. Also if I build it in shell, and then delete everything but the parent pom(s), then the job in Jenkins builds fine downloading the required artifacts. So the problem seems to only affect downloadin the parent -artifacts.

      Parsing POMs
      Failed to transfer Could not transfer metadata <name-stuffs removed>:pom:1.0-SNAPSHOT/maven-metadata.xml from/to server.company.com (https://server.company.com/snapshot/): Not authorized.
      Failed to transfer Could not transfer artifact <name-stuffs-removed>-pom:pom:1.0-SNAPSHOT from/to server.company.com (https://server.company.com/snapshot/): Not authorized.
      ERROR: Failed to parse POMs
      org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
      [FATAL] Non-resolvable parent POM: Could not transfer artifact <name-stuffs-removed>-pom:pom:1.0-SNAPSHOT from/to server.company.com (https://server.company.com/snapshot/): Not authorized. and 'parent.relativePath' points at wrong local POM @ line 3, column 10

      at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:339)
      at hudson.maven.MavenEmbedder.buildProjects(MavenEmbedder.java:361)
      at hudson.maven.MavenEmbedder.readProjects(MavenEmbedder.java:331)
      at hudson.maven.MavenEmbedder.readProject(MavenEmbedder.java:322)
      at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1244)
      at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1065)
      at hudson.FilePath.act(FilePath.java:783)
      at hudson.FilePath.act(FilePath.java:765)
      at hudson.maven.MavenModuleSetBuild$RunnerImpl.parsePoms(MavenModuleSetBuild.java:930)
      at hudson.maven.MavenModuleSetBuild$RunnerImpl.doRun(MavenModuleSetBuild.java:658)
      at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:462)
      at hudson.model.Run.run(Run.java:1404)
      at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:481)
      at hudson.model.ResourceController.execute(ResourceController.java:88)
      at hudson.model.Executor.run(Executor.java:238)
      Description set:
      Finished: FAILURE

          [JENKINS-12041] Maven build fails with empty local repository to "Not Authorized"

          Petteri Kauko added a comment -

          Jenkins version is 1.442.

          Petteri Kauko added a comment - Jenkins version is 1.442.

          Petteri Kauko added a comment -

          As I finally had time to dig into this, I found out that by default the embedded maven tries to find the maven settings under the users home dir in .m2 directory. And the embedded maven seems to always be used when parsing poms, regardless of any maven installations you add to jenkins. When I put a settings.xml with valid logon credentials in the aforementioned directory, this seems to work.

          Petteri Kauko added a comment - As I finally had time to dig into this, I found out that by default the embedded maven tries to find the maven settings under the users home dir in .m2 directory. And the embedded maven seems to always be used when parsing poms, regardless of any maven installations you add to jenkins. When I put a settings.xml with valid logon credentials in the aforementioned directory, this seems to work.

            Unassigned Unassigned
            pkauko Petteri Kauko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: