0

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.

2
  • 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: jenkins.io/doc/pipeline/steps/workflow-basic-steps/…)
    – jayhendren
    Aug 18 at 15:58
  • @jayhendren Thanks for the reply. I figured out the issue. I will add that as an answer.
    – kalanatd
    Aug 23 at 4:34
0

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

Now a simple pipeline uses the Squid proxy settings without any issue. A wget connects to the Squid proxy without any issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.