-
Improvement
-
Resolution: Unresolved
-
Minor
-
None
-
n/a
We're using declarative piplelines for a number of build and test jobs, and all our systems are behind a proxy; depending on the DMZ the Jenkins instance is in, there are different proxy settings necessary.
We'd like to access the Jenkins proxy settings as variables when running Groovy or shell scripts. Right now, this has to be added through a script {} block; we'd like the Pipeline plugin to provide these settings as standard variables in the default scope.
This is a snippet of the code we're using right now:
pipeline { agent any stages { stage('Preparation') { steps { script { def p = jenkins.model.Jenkins.getInstance().proxy env['http_proxy'] = "http://${p.name}:${p.port}" env['https_proxy'] = env['http_proxy'] env['no_proxy'] = p.noProxyHost } } } stage('Build') { steps { sh 'docker build -t mms_builder_dockerrpm --build-arg http_proxy="${http_proxy}" --build-arg https_proxy="${https_proxy}" --build-arg no_proxy="${no_proxy}" .' } } }
Ideally, we could simply access the ProxyConfig variables as Groovy or environment variables, or both.
I'd say this is a more general matter than just Declarative - you're looking to get more information added to the environment available throughout the Pipeline. I'd prefer to address that across all of Pipeline, not just Declarative.