fabric8io / jenkins-pipeline-library

a collection of reusable jenkins pipelines and pipeline functions
Apache License 2.0
275 stars 180 forks source link

Problem with Groovy script from Jenkins-pipeline-library and HTTP proxy requirements on corporate network #136

Closed LarsMilland closed 8 years ago

LarsMilland commented 8 years ago

Hi

I am trying to get an OpenShift/Fabric8 installation working with the Fabric8 jenkins pipelines running on a Maven/Java project.

I have the fabric8/maven-builder docker images launched on the OpenShift instance, but every time the build starts up it hangs on some network connection timeout. See below.

My guess is that the problem is caused by our network setup requiring to use a proxy server to access to the internet for HTTP connections.

I have tried to set different JAVA_OPTS and http_proxy/https_proxy environment variables to the fabric8/maven-builder docker image as it is launched by the Jenkins pipeline code. But this is ont helping me yet. Have you got any ideas on how to get the PROXY server configuration into the Groovy scripts?

Fetching changes from the remote Git repository Checking out Revision 12e53a3244897549e007ef520dbf04fc77e227b5 (refs/remotes/origin/master) [Pipeline] Allocate node : Start Running on 2d2d7c2ca0786 in /home/jenkins/workspace/workspace/springboot [Pipeline] node { [Pipeline] git Fetching changes from the remote Git repository Checking out Revision 12e53a3244897549e007ef520dbf04fc77e227b5 (refs/remotes/origin/master) [Pipeline] echo NOTE: running pipelines for the first time will take longer as build and base docker images are pulled onto the node [Pipeline] Run build steps in a Pod : Start [Pipeline] withPod { [Pipeline] stage (Canary Release) Entering stage Canary Release Proceeding [Pipeline] } //withPod [Pipeline] Run build steps in a Pod : End [Pipeline] } //node [Pipeline] Allocate node : End [Pipeline] End of Pipeline Found Elasticsearch server, sending:{"timestamp":"2016-06-30T13:37:52.589+0000","build_number":5,"app":"springboot","build_result":"FAILURE","start_time":"2016-06-30T13:37:52.590+0000","duration":0,"environment":{"BUILD_DISPLAY_NAME":"#5","BUILD_ID":"5","BUILD_NUMBER":"5","BUILD_TAG":"jenkins-springboot-5","CLASSPATH":"","HUDSON_HOME":"/var/jenkins_home","HUDSON_SERVER_COOKIE":"3e6183a8397a33a2","JENKINS_HOME":"/var/jenkins_home","JENKINS_SERVER_COOKIE":"3e6183a8397a33a2","JOB_NAME":"springboot"},"build_url":"job/springboot/5/","causes":[{"short_description":"Started by user anonymous","user_name":"anonymous"}]} Event created java.net.ConnectException: Connection timed out at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ....

at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:15)
at io.fabric8.Fabric8Commands.getReleaseVersion(file:/var/jenkins_home/workflow-libs/src/io/fabric8/Fabric8Commands.groovy:12)
at mavenCanaryRelease.call(/var/jenkins_home/workflow-libs/vars/mavenCanaryRelease.groovy:10)
at WorkflowScript.run(WorkflowScript:46)
at io.fabric8.kubernetes.workflow.Kubernetes$Pod.inside(jar:file:/var/jenkins_home/plugins/kubernetes-steps/WEB-INF/lib/kubernetes-steps.jar!/io/fabric8/kubernetes/workflow/Kubernetes.groovy:123)
at ___cps.transform___(Native Method)
at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:55)

....

Finished: FAILURE

LarsMilland commented 8 years ago

Hi again

I have solved the problem myself I think, with injecting proper Java System properties through the groovy scripts of the Jenkins pipeline.

System.getProperties().put("proxySet", "true"); System.getProperties().put("http.proxyHost", "theproxyhost.xx.yy"); System.getProperties().put("http.proxyPort", "8080"); System.getProperties().put("https.proxyHost", "theproxyhost.xx.yy"); System.getProperties().put("https.proxyPort", "8080"); System.getProperties().put("http.nonProxyHosts", "*.domainy.local|*.domainx.local"); And then in the Jenkins configuration administration panel "In-process Script Approval" granting Groovy script engine the required permissions to the needed methods.

Best regards Lars Milland