jenkins 设置proxy_如何在单个构建中禁用Jenkins中的代理设置

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://joeuser@bitbucket.org/team/app.git

> /usr/bin/git init /home/jenkins/workspace/Angular Projects/app/building-svcs-aws2 # timeout=10

Fetching upstream changes from https://joeuser@bitbucket.org/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://joeuser@bitbucket.org/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://joeuser@bitbucket.org/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. ...

解决方案

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).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值