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

Deploy artifacts to Maven repository ignores Global MAVEN_OPTS

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • maven-plugin
    • None
    • Maven Integration plugin 2.14
      Jenkins ver. 2.19.3

      We use a keystore with client certificates to authenticate with remote severs. We normally use MAVEN_OPTS to pass JDK -Djavax.net.ssl.keyStore parameters to Maven

      This works for a Maven project, and Invoke top-level Maven targets steps.

      However the setting is ignored in the Deploy artifacts to Maven repository step/publisher. Setting a normal MAVEN_OPTS via EnjInject plugin also seems to have no effect

      Sample output (with haproxy's verify optional):

      Maven RedeployPublisher use remote IQ-449a33ad36b4 maven settings from : /tmp/settings2743001247239769636.xml
      [INFO] Deployment in https://mvnrepo.acme-it.com/content/repositories/snapshots/ (id=,uniqueVersion=true)
      Deploying the main artifact aggregator-29.3.0-SNAPSHOT.pom
      Downloading: https://mvnrepo.acme-it.com/content/repositories/snapshots/com/acme/aggregator/29.3.0-SNAPSHOT/maven-metadata.xml
      ERROR: Failed to retrieve remote metadata com.acme:aggregator:29.3.0-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.acme:aggregator:29.3.0-SNAPSHOT/maven-metadata.xml from/to  (https://mvnrepo.acme-it.com/content/repositories/snapshots/): Not authorized , ReasonPhrase:Unauthorized.
      org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to retrieve remote metadata com.acme:aggregator:29.3.0-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.acme:aggregator:29.3.0-SNAPSHOT/maven-metadata.xml from/to  (https://mvnrepo.acme-it.com/content/repositories/snapshots/): Not authorized , ReasonPhrase:Unauthorized.

      Also adding a per-step JVM Options field (like Invoke top-level Maven targets) would be nice

          [JENKINS-40011] Deploy artifacts to Maven repository ignores Global MAVEN_OPTS

          If Haproxy has mandatory client cert verification the output is (a bit misleading):

          [INFO] Deployment in https://mvnrepo.acme-it.com:5972/content/repositories/snapshots/ (id=snapshots,uniqueVersion=true)
          Deploying the main artifact aggregator-0.0.1-SNAPSHOT.pom
          Downloading: https://mvnrepo.acme-it.com:5972/content/repositories/snapshots/com/acme/aggregator/0.0.1-SNAPSHOT/maven-metadata.xml
          ERROR: Failed to retrieve remote metadata com.acme:aggregator:0.0.1-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.acme:aggregator:0.0.1-SNAPSHOT/maven-metadata.xml from/to snapshots (https://mvnrepo.acme-it.com:5972/content/repositories/snapshots/): Received fatal alert: handshake_failure
          org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to retrieve remote metadata com.acme:aggregator:0.0.1-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.acme:aggregator:0.0.1-SNAPSHOT/maven-metadata.xml from/to snapshots (https://mvnrepo.acme-it.com:5972/content/repositories/snapshots/): Received fatal alert: handshake_failure

          Jakub Bochenski added a comment - If Haproxy has mandatory client cert verification the output is (a bit misleading): [INFO] Deployment in https: //mvnrepo.acme-it.com:5972/content/repositories/snapshots/ (id=snapshots,uniqueVersion= true ) Deploying the main artifact aggregator-0.0.1-SNAPSHOT.pom Downloading: https: //mvnrepo.acme-it.com:5972/content/repositories/snapshots/com/acme/aggregator/0.0.1-SNAPSHOT/maven-metadata.xml ERROR: Failed to retrieve remote metadata com.acme:aggregator:0.0.1-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.acme:aggregator:0.0.1-SNAPSHOT/maven-metadata.xml from/to snapshots (https: //mvnrepo.acme-it.com:5972/content/repositories/snapshots/): Received fatal alert: handshake_failure org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to retrieve remote metadata com.acme:aggregator:0.0.1-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.acme:aggregator:0.0.1-SNAPSHOT/maven-metadata.xml from/to snapshots (https: //mvnrepo.acme-it.com:5972/content/repositories/snapshots/): Received fatal alert: handshake_failure

          Deploy works fine when using user/password authentication:

          Maven RedeployPublisher use remote IQ-449a33ad36b4 maven settings from : /tmp/settings5578981742753340929.xml
          [INFO] Deployment in https://mvnrepo.acme-it.com/content/repositories/snapshots/ (id=nexus,uniqueVersion=true)
          Deploying the main artifact aggregator-29.3.0-SNAPSHOT.pom
          Downloading: https://mvnrepo.acme-it.com/content/repositories/snapshots/com/purato/aggregator/29.3.0-SNAPSHOT/maven-metadata.xml
          Downloaded: https://mvnrepo.acme-it.com/content/repositories/snapshots/com/purato/aggregator/29.3.0-SNAPSHOT/maven-metadata.xml (601 B at 1.9 KB/sec)
          Uploading: https://mvnrepo.acme-it.com/content/repositories/snapshots/com/purato/aggregator/29.3.0-SNAPSHOT/aggregator-29.3.0-20161124.155824-18.pom
          Uploaded: https://mvnrepo.acme-it.com/content/repositories/snapshots/com/purato/aggregator/29.3.0-SNAPSHOT/aggregator-29.3.0-20161124.155824-18.pom (8 KB at 86.0 KB/sec)

          Jakub Bochenski added a comment - Deploy works fine when using user/password authentication: Maven RedeployPublisher use remote IQ-449a33ad36b4 maven settings from : /tmp/settings5578981742753340929.xml [INFO] Deployment in https: //mvnrepo.acme-it.com/content/repositories/snapshots/ (id=nexus,uniqueVersion= true ) Deploying the main artifact aggregator-29.3.0-SNAPSHOT.pom Downloading: https: //mvnrepo.acme-it.com/content/repositories/snapshots/com/purato/aggregator/29.3.0-SNAPSHOT/maven-metadata.xml Downloaded: https: //mvnrepo.acme-it.com/content/repositories/snapshots/com/purato/aggregator/29.3.0-SNAPSHOT/maven-metadata.xml (601 B at 1.9 KB/sec) Uploading: https: //mvnrepo.acme-it.com/content/repositories/snapshots/com/purato/aggregator/29.3.0-SNAPSHOT/aggregator-29.3.0-20161124.155824-18.pom Uploaded: https: //mvnrepo.acme-it.com/content/repositories/snapshots/com/purato/aggregator/29.3.0-SNAPSHOT/aggregator-29.3.0-20161124.155824-18.pom (8 KB at 86.0 KB/sec)

          Mark Cranny added a comment -

          Jenkins: 2.39
          Maven Integration Plugin: 2.14

          We get a similar problem: Maven on the command line or Freestyle Project/top-level Maven project uses the keystore config from MAVEN_OPTS successfully but the Maven Plugin fails to honour them:-

          Parsing POMs
          Failed to transfer Could not transfer artifact maven.parents:service:pom:1.1 from/to internal-repository 
          (https://<domain>/artifactory/repo/): Received fatal alert: handshake_failure
          ERROR: Failed to parse POMs
          java.io.IOException: remote file operation failed: /var/lib/jenkins/workspace/cps-publisher at
          hudson.remoting.Channel@c13575a:Channel to /<ip address>: hudson.remoting.ProxyException:
          hudson.maven.MavenModuleSetBuild$MavenExecutionException: 
          org.apache.maven.project.ProjectBuildingException: 
          Some problems were encountered while processing the POMs:[FATAL] Non-resolvable parent POM: 
          Could not transfer artifact maven.parents:service:pom:1.1 from/to internal-repository 
          (https://<domain>/artifactory/repo/): Received fatal alert: handshake_failure and 'parent.relativePath' points at 
          wrong local POM @ line 11, column 10
          

          Mark Cranny added a comment - Jenkins: 2.39 Maven Integration Plugin: 2.14 We get a similar problem: Maven on the command line or Freestyle Project/top-level Maven project uses the keystore config from MAVEN_OPTS successfully but the Maven Plugin fails to honour them:- Parsing POMs Failed to transfer Could not transfer artifact maven.parents:service:pom:1.1 from/to internal-repository (https://<domain>/artifactory/repo/): Received fatal alert: handshake_failure ERROR: Failed to parse POMs java.io.IOException: remote file operation failed: /var/lib/jenkins/workspace/cps-publisher at hudson.remoting.Channel@c13575a:Channel to /<ip address>: hudson.remoting.ProxyException: hudson.maven.MavenModuleSetBuild$MavenExecutionException: org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:[FATAL] Non-resolvable parent POM: Could not transfer artifact maven.parents:service:pom:1.1 from/to internal-repository (https://<domain>/artifactory/repo/): Received fatal alert: handshake_failure and 'parent.relativePath' points at wrong local POM @ line 11, column 10

          We're having a similar issue when attempting to download a parent pom using client cert auth.

          Has anyone found a workaround?

           

          Jenkins 2.46.3

          Maven Integration Plugin: 2.17

           

          Parsing POMs
          Failed to transfer Could not transfer artifact com.entparent:luna:pom:2.0 from/to public-repos (https://<url>/public-repos): Received fatal alert: handshake_failure
          
          $ ssh-agent -k
          unset SSH_AUTH_SOCK;
          unset SSH_AGENT_PID;
          echo Agent pid 12903 killed;
          [ssh-agent] Stopped.
          ERROR: Failed to parse POMs
          java.io.IOException: remote file operation failed: /var/lib/jenkins/workspace/portalrel-code-unlock-dash-api-master at hudson.remoting.Channel@7d058a25:lunabuild-qa-slave-1: hudson.remoting.ProxyException: hudson.maven.MavenModuleSetBuild$MavenExecutionException: org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
          [FATAL] Non-resolvable parent POM: Could not transfer artifact com.entparent:luna:pom:2.0 from/to public-repos (https://<url/public-repos): Received fatal alert: handshake_failure and 'parent.relativePath' points at wrong local POM @ line 7, column 13
          
              at hudson.FilePath.act(FilePath.java:992)
              at hudson.FilePath.act(FilePath.java:974)
              at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.parsePoms(MavenModuleSetBuild.java:985)
              at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:690)
              at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
              at hudson.model.Run.execute(Run.java:1728)
              at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:542)
              at hudson.model.ResourceController.execute(ResourceController.java:98)
              at hudson.model.Executor.run(Executor.java:405)
          Caused by: hudson.remoting.ProxyException: hudson.maven.MavenModuleSetBuild$MavenExecutionException: org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:

          Christopher Stafford added a comment - We're having a similar issue when attempting to download a parent pom using client cert auth. Has anyone found a workaround?   Jenkins 2.46.3 Maven Integration Plugin: 2.17   Parsing POMs Failed to transfer Could not transfer artifact com.entparent:luna:pom:2.0 from/to public -repos (https: //<url>/ public -repos): Received fatal alert: handshake_failure $ ssh-agent -k unset SSH_AUTH_SOCK; unset SSH_AGENT_PID; echo Agent pid 12903 killed; [ssh-agent] Stopped. ERROR: Failed to parse POMs java.io.IOException: remote file operation failed: / var /lib/jenkins/workspace/portalrel-code-unlock-dash-api-master at hudson.remoting.Channel@7d058a25:lunabuild-qa-slave-1: hudson.remoting.ProxyException: hudson.maven.MavenModuleSetBuild$MavenExecutionException: org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs: [FATAL] Non-resolvable parent POM: Could not transfer artifact com.entparent:luna:pom:2.0 from/to public -repos (https: //<url/ public -repos): Received fatal alert: handshake_failure and 'parent.relativePath' points at wrong local POM @ line 7, column 13     at hudson.FilePath.act(FilePath.java:992)     at hudson.FilePath.act(FilePath.java:974)     at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.parsePoms(MavenModuleSetBuild.java:985)     at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:690)     at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)     at hudson.model.Run.execute(Run.java:1728)     at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:542)     at hudson.model.ResourceController.execute(ResourceController.java:98)     at hudson.model.Executor.run(Executor.java:405) Caused by: hudson.remoting.ProxyException: hudson.maven.MavenModuleSetBuild$MavenExecutionException: org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:

          cstaffor my advice is to heed stephenconnolly advice and don't use Jenkins-Maven integration: https://javaadventure.blogspot.com/2013/11/jenkins-maven-job-type-considered-evil.html

          When it blows up, and it will blow up, it blows up big

          You could try https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html#deployAtEnd with regular deploy goal.

          What we do is we actually create a local Maven repository with the job's artifacts, then just archive it so that other jobs/Nexus can access it.
          This is almost the same that pipeline-maven plugin does, you can check JENKINS-45405 for details

          Jakub Bochenski added a comment - cstaffor my advice is to heed stephenconnolly advice and don't use Jenkins-Maven integration: https://javaadventure.blogspot.com/2013/11/jenkins-maven-job-type-considered-evil.html When it blows up, and it will blow up, it blows up big You could try https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html#deployAtEnd with regular deploy goal. What we do is we actually create a local Maven repository with the job's artifacts, then just archive it so that other jobs/Nexus can access it. This is almost the same that pipeline-maven plugin does, you can check JENKINS-45405 for details

          cstaffor sorry I've only now noticed you are asking about download.

          I believe MAVEN_OPTs are honored for the regular steps. It was broken too, but at some point it has been fixed.

          The best workaround we were able to come up for the download problem at the time was to first run mvn dependency:go-offline dependency:resolve-plugins from the CLI before running regular steps in a Jenkins-Maven step/job

          Jakub Bochenski added a comment - cstaffor sorry I've only now noticed you are asking about download. I believe MAVEN_OPTs are honored for the regular steps. It was broken too, but at some point it has been fixed. The best workaround we were able to come up for the download problem at the time was to first run mvn dependency:go-offline dependency:resolve-plugins from the CLI before running regular steps in a Jenkins-Maven step/job

            Unassigned Unassigned
            jbochenski Jakub Bochenski
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: