Answers: <p>My <code>sh &quot;&quot;&quot; commands &quot;&quot;&quot;</code> step was not using the $http_proxy environment variable mentioned in the .bashrc or /etc/profile.</p>
  <p>What I did was using the Jenkins <code>Prepare an environment for the run</code> option and adding my values.</p>
  <p><a href="https://i.sstatic.net/6siYV.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/6siYV.png" alt="enter image description here" /></a></p>
  <p>Now a simple pipeline uses the Squid proxy settings without any issue. A wget connects to the Squid proxy without any issue.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-08-23T04:39:49.387Z
Answers: 2021-08-23T04:39:49.387Z
Answers: kalanatd
Body: <p>I have configured a Squid Proxy and it seems to be working when I add below Env variables to the /home/user/.bashrc file to a client machine.
  Note: SSL Bump is configured, Self Signed Cert is added to the /etc/ssl/certs and the cert is being trusted.</p>
  <pre><code>export http_proxy=http://172.12.1.100:3128/
  export https_proxy=http://172.12.1.100:3128/
  </code></pre>
  <p>For example when I run</p>
  <pre><code>user@squid-client:$ echo $http_proxy
  http://172.12.1.100:3128/
  
  user@squid-client:/tmp$ wget https://google.com
  
  --2021-08-17 09:42:14--  https://google.com/
  Connecting to 172.12.1.100:3128... connected.
  Proxy request sent, awaiting response... 301 Moved Permanently
  Location: https://www.google.com/ [following]
  --2021-08-17 09:42:14--  https://www.google.com/
  Connecting to 172.12.1.100:3128... connected.
  Proxy request sent, awaiting response... 200 OK
  Length: unspecified [text/html]
  Saving to: ‘index.html.1’
  
  index.html.1                       [ &lt;=&gt;                                                 ]  12.68K  --.-KB/s    in 0s
  
  2021-08-17 09:42:15 (42.6 MB/s) - ‘index.html.1’ saved [12986]
  </code></pre>
  <p>Now I connected this Linux instance to my Jenkins Master as a slave (Unix Slave via SSH) and run a simple pipeline script which basically has the same wget command.</p>
  <p>But the squid access log nor the Jenkins Console output does not show anything related to the Squid Proxy.</p>
  <p>Here is the part of the console output from that Jenkins Job.</p>
  <pre><code>+ wget google.com
  --2021-08-17 09:26:39--  http://google.com/
  Resolving google.com (google.com)... 142.251.40.78, 2607:f8b0:4023:1002::64, 2607:f8b0:4023:1002::8a, ...
  Connecting to google.com (google.com)|142.251.40.78|:80... connected.
  HTTP request sent, awaiting response... 301 Moved Permanently
  Location: http://www.google.com/ [following]
  --2021-08-17 09:26:39--  http://www.google.com/
  Resolving www.google.com (www.google.com)... 142.250.68.164, 2607:f8b0:4023:1006::6a, 2607:f8b0:4023:1006::93, ...
  Connecting to www.google.com (www.google.com)|142.250.68.164|:80... connected.
  HTTP request sent, awaiting response... 200 OK
  Length: unspecified [text/html]
  Saving to: ‘index.html.4’
  </code></pre>
  <p>I executed the &quot;printenv&quot; command via the pipeline and it also does not show $http_proxy variable.</p>
  <p>I want my jobs to download packages, files via this Squid Proxy Server. Any help would be really appreciated.</p>
  <p>Note 2: I tried to source /etc/profile (after adding the export http_proxy lines to that file) and seems source is not supported in whatever the shell used by the Jenkins slave service.</p>
  <p>Note 3: Both The Squid Proxy and the Client (Jenkins Slave )runs on Ubuntu 18.04.</p>
  
Comments: CC BY-SA 4.0
Comments: 2021-08-18T15:58:55.400Z
Comments: 2 comments: 1.  Can you paste your pipeline code?  It's hard to debug your code if we can't see it.  2.  In Jenkins Pipeline, you will typically need to use the `withEnv` wrapper step in order to set environment variables (documentation here: https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/#withenv-set-environment-variables)
Comments: jayhendren
Comments: CC BY-SA 4.0
Comments: 2021-08-23T04:34:09.157Z
Comments: @jayhendren Thanks for the reply. I figured out the issue. I will add that as an answer.
Comments: kalanatd
Tags: <jenkins><jenkins-pipeline>
Title: Jenkins Pipeline job does not use Squid Proxy
UserDisplayName: kalanatd
ThreadText: # Jenkins Pipeline job does not use Squid Proxy
  
  (Asked by: username_0 on 2021-08-17)
  
  I have configured a Squid Proxy and it seems to be working when I add below Env variables to the /home/user/.bashrc file to a client machine.
  Note: SSL Bump is configured, Self Signed Cert is added to the /etc/ssl/certs and the cert is being trusted.
  
  ```
  export http_proxy=http://172.12.1.100:3128/
  export https_proxy=http://172.12.1.100:3128/
  
  ```
  
  For example when I run
  
  ```
  user@squid-client:$ echo $http_proxy
  http://172.12.1.100:3128/
  
  user@squid-client:/tmp$ wget https://google.com
  
  --2021-08-17 09:42:14--  https://google.com/
  Connecting to 172.12.1.100:3128... connected.
  Proxy request sent, awaiting response... 301 Moved Permanently
  Location: https://www.google.com/ [following]
  --2021-08-17 09:42:14--  https://www.google.com/
  Connecting to 172.12.1.100:3128... connected.
  Proxy request sent, awaiting response... 200 OK
  Length: unspecified [text/html]
  Saving to: ‘index.html.1’
  
  index.html.1                       [ <=>                                                 ]  12.68K  --.-KB/s    in 0s
  
  2021-08-17 09:42:15 (42.6 MB/s) - ‘index.html.1’ saved [12986]
  
  ```
  
  Now I connected this Linux instance to my Jenkins Master as a slave (Unix Slave via SSH) and run a simple pipeline script which basically has the same wget command.
  
  But the squid access log nor the Jenkins Console output does not show anything related to the Squid Proxy.
  
  Here is the part of the console output from that Jenkins Job.
  
  ```
  + wget google.com
  --2021-08-17 09:26:39--  http://google.com/
  Resolving google.com (google.com)... 142.251.40.78, 2607:f8b0:4023:1002::64, 2607:f8b0:4023:1002::8a, ...
  Connecting to google.com (google.com)|142.251.40.78|:80... connected.
  HTTP request sent, awaiting response... 301 Moved Permanently
  Location: http://www.google.com/ [following]
  --2021-08-17 09:26:39--  http://www.google.com/
  Resolving www.google.com (www.google.com)... 142.250.68.164, 2607:f8b0:4023:1006::6a, 2607:f8b0:4023:1006::93, ...
  Connecting to www.google.com (www.google.com)|142.250.68.164|:80... connected.
  HTTP request sent, awaiting response... 200 OK
  Length: unspecified [text/html]
  Saving to: ‘index.html.4’
  
  ```
  
  I executed the "printenv" command via the pipeline and it also does not show $http\_proxy variable.
  
  I want my jobs to download packages, files via this Squid Proxy Server. Any help would be really appreciated.
  
  Note 2: I tried to source /etc/profile (after adding the export http\_proxy lines to that file) and seems source is not supported in whatever the shell used by the Jenkins slave service.
  
  Note 3: Both The Squid Proxy and the Client (Jenkins Slave )runs on Ubuntu 18.04.
  
  **Tags:** jenkins, jenkins-pipeline
  
  > **Comments:**
  > **username_1**: 2 comments: 1.  Can you paste your pipeline code?  It's hard to debug your code if we can't see it.  2.  In Jenkins Pipeline, you will typically need to use the `withEnv` wrapper step in order to set environment variables (documentation here: https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/#withenv-set-environment-variables)  
  > **username_0**: @username_1 Thanks for the reply. I figured out the issue. I will add that as an answer.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-08-23. Score: 0 | Accepted answer
  
  My `sh """ commands """` step was not using the $http\_proxy environment variable mentioned in the .bashrc or /etc/profile.
  
  What I did was using the Jenkins `Prepare an environment for the run` option and adding my values.
  
  [![enter image description here](https://i.sstatic.net/6siYV.png)](https://i.sstatic.net/6siYV.png)
  
  Now a simple pipeline uses the Squid proxy settings without any issue. A wget connects to the Squid proxy without any issue.
  
  
  ---
  
  