如何在单个构建中禁用Jenkins中的代理设置 [英] 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.
但是,我想使用AWS机器进行一些构建,但是当然那些不需要代理.我无法完全关闭代理,否则其他版本会崩溃.
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.
我原本打算搬到ssh://
,但仍然会遇到我认为的npm
,maven
等问题....
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.
提出的解决方案是,特定于节点的代理设置将优先于全局代理定义.我假设 EnvInject 插件也可以用于更改然后在工作中使用代理设置.
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.
该解决方案尚未发布. 暂时的解决方法:
- 在全局代理配置中,为所有git服务器设置无代理主机"例外,或者
- 禁用全局代理配置,仅在需要与更新中心联系时(手动)重新启用它,或
- 在您的工作中明确运行
git
命令(但这仅涵盖最简单的用例).
- 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).
这篇关于如何在单个构建中禁用Jenkins中的代理设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!