简体   繁体   中英

Jenkins scripted pipeline job failing because of GLOBAL MAVEN_OPTS not available in script

1.I have Jenkins pipeline job which doing simple demo task 'mvn clean' on a certain maven project. 2. mvn clean is going to download some plugin jar from company's central maven repository. 3. Machine is configured with with MAVEN_OPTS at global/system level. 4. When I am executing same 'mvn' clean command from shell as user 'jenkins' then its working fine and build is successful. 5. But When my Jenkins pipeline execute same command its failing and throwing certification error. 6. Below is the error 'PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target'

One of my colleague explained me reason as below. Job is failing because Jenkins start another child process( mvn clean) and that child job do not have access to the system level environment variable. Solution is

  1. put certification path in every mvn command like below "mvn clean -Djavax.net.ssl.trustStore=/etc/pki/tls/certs/wd-truststore -Djavax.net.ssl.trustStorePassword=changei"

or 2. Configure jenkins job and at 'Build Environment' Section in 'Execute shell' mention command to execute the shell script to set MAVEN_OPTS as below

"echo mavenOpts='-Xmx2g -Djavax.net.ssl.trustStore=wd-truststore -Djavax.net.ssl.trustStorePassword=changeit"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM