Pompey Magnus
Pompey Magnus

Reputation: 2341

How to disable the proxy setting in Jenkins for a single build

We have our build nodes behind a corporate firewall and allow it out via a proxy to get stuff. So we have the proxy info set in the plugin manager.

However, I'd like to use AWS machines to do some building, but of course those don't need a proxy. I can't turn the proxy completely off or the other builds will break.

Is there a way to turn off or override the globally set proxy on a specific build?

Cloning the remote Git repository
Cloning repository https://[email protected]/team/app.git
 > /usr/bin/git init /home/jenkins/workspace/Angular Projects/app/building-svcs-aws2 # timeout=10
Fetching upstream changes from https://[email protected]/team/app.git
 > /usr/bin/git --version # timeout=10
using .gitcredentials to set credentials
 > /usr/bin/git config --local credential.username joeuser # timeout=10
 > /usr/bin/git config --local credential.helper store --file=/tmp/git7307041699576258044.credentials # timeout=10
Setting http proxy: proxyna.server.com:8060
 > /usr/bin/git -c core.askpass=true fetch --tags --progress https://[email protected]/team/app.git +refs/heads/*:refs/remotes/origin/*
 > /usr/bin/git config --local --remove-section credential # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "/usr/bin/git -c core.askpass=true fetch --tags --progress https://[email protected]/team/app.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:

You can see it injecting the proxy, I was surprised to find it get set there automatically from where it was configured in the plugins section. But if I remove the proxy setting there, the code checks out just fine.

I was going to move to ssh:// but I'll still have the problem I think with npm, maven, etc. ...

Upvotes: 2

Views: 18398

Answers (1)

Alex O
Alex O

Reputation: 8164

This (kind of unexpected) behavior is currently discussed in Jenkins issue 31464.

The solution proposed there is that node-specific proxy settings will take precedence over the global proxy definition. I'd assume that also the EnvInject plugin could be used to change the proxy setting within a job then.

That solution has not been released yet, though. Possible work-arounds for the time being:

  • in the global proxy config, set the "No proxy host" exception for all your git servers, or
  • disable the global proxy config, and only re-enable it (manually) when you need to contact the update center, or
  • explicitly run the git command in your job (but this will only cover the most simple use cases).

Upvotes: 2

Related Questions