Jenkins pipeline using docker agent can’t push on artifactory due to jvm cacert

I need to push some jar files obtained during a Jenkins pipeline, to Jfrog;
below the code:

stage ('Artifactory configuration') {
            when { expression { params.runDelivery } }
            steps {
                rtServer (
                    id: "artifactory",
                    url: "https://jfroglocal/artifactory",
                    credentialsId: "jfrog"
                )

                rtMavenDeployer (
                    id: "MAVEN_DEPLOYER",
                    serverId: "artifactory",
                    releaseRepo: "example-repo-local",
                    snapshotRepo: "example-repo-local"
                )
            }
        }

here the error:

[m org.apache.maven.cli.MavenCli -  Skipping deployment of remaining artifacts (if any) and build info. sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target etc

if I run the pipeline directly from the “jenkins slave server” the error disappear after linkng /usr/lib/jvm/java-11-openjdk-amd64/lib/security/cacert to /etc/ssl/certs/java/cacerts

if I run the same pipeline from an docker agent the error persists; below the declared agent:

agent {
        docker {
            label 'Ubuntu-20.04-Slave'
            image 'node:10'
            args '-u root'
        }

    }

how can i link the cacert file (of the jenkins slave) into the container?

there is a way to configure jenkins to share the JVM cacert with the container?

Answer

Attribution
Source : Link , Question Author : rugby82 , Answer Author : Community

Leave a Comment