Gradle 代理配置 [英] Gradle proxy configuration

查看:74
本文介绍了Gradle 代理配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过代理服务器从 Gradle 访问 Web,以便为 Jenkins 使用 Gradle/Artifactory 集成.为了减少问题的可能原因,我在 build.gradle 中手动添加了 Artifactory 插件并从命令行运行它:

I need web access from Gradle through a proxy server to use the Gradle/Artifactory integration for Jenkins. To reduce possible causes for issues, I manually add the Artifactory plugin in build.gradle and run it from command line:

apply {
    apply from: "http://gradle.artifactoryonline.com/gradle/plugins/org/jfrog/buildinfo/build-info-extractor-gradle/1.0.1/artifactoryplugin-1.0.1.gradle"
}

根据 this 描述,我在.gradle/gradle.properties 在我的主目录中:

Following this description I specified the following in .gradle/gradle.properties in my home directory:

systemProp.http.proxyHost=hostname
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=de\username
systemProp.http.proxyPassword=xxx

使用上述代理配置(已知可以工作),它失败了:

With the above proxy configuration (that is otherwise known to work), it fails:

11:33:17.699 [ERROR] [org.gradle.BuildExceptionReporter] 由:java.io.IOException:服务器返回 HTTP 响应代码:407 for URL:http://gradle.artifactoryonline.com/gradle/plugins/org/jfrog/buildinfo/build-info-extractor-gradle/1.0.1/artifactoryplugin-1.0.1.gradle

11:33:17.699 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.io.IOException: Server returned HTTP response code: 407 for URL: http://gradle.artifactoryonline.com/gradle/plugins/org/jfrog/buildinfo/build-info-extractor-gradle/1.0.1/artifactoryplugin-1.0.1.gradle

我有两个代理服务器可供选择,一个总是以 407(需要代理身份验证)响应,另一个以 502(Bad gateway),很明显,使用了 proxyHost 和 proxyPort 选项.

I have two proxy servers to choose from, and one always responds with 407 (Proxy authentication required), the other with 502 (Bad gateway), so obviously, the proxyHost and proxyPort options are used.

由于用户名(基于 Active Directory 用户)包含反斜杠,我尝试了 \,但都没有奏效.指定的用户不同于登录到机器和 Active Directory 的用户.此用户的凭据对代理无效,因此我需要能够指定其他用户.

As the user name (based on an Active Directory user) contains a backslash, I tried both \ and , but neither worked. The user specified is different from the user that is logged in to the machine and Active Directory. This user's credentials aren't valid for the proxy, so I need to be able to specify a different user.

在 Jenkins 或 Artifactory 的 GUI 中设置相同的选项有效.

Setting the same options in Jenkins' or Artifactory's GUI worked.

推荐答案

使用非常简单的请求 URL"Java 程序,我能够重现该问题.

Using a very simple "Request a URL" Java program, I was able to replicate the issue.

http.proxyUserhttp.proxyPassword 似乎是非标准的但很受欢迎的选项,因为它们没有在 从 Gradle 教程链接的 Java 参考页面;即使 Gradle 手册提到了它们.

http.proxyUser and http.proxyPassword seem to be non-standard, albeit popular, options, as they're not described in the Java reference page linked from the Gradle tutorial; even though the Gradle manual mentions them.

似乎希望支持代理身份验证的 Java 程序需要手动执行此操作(我可以使用链接页面上的代码执行此操作).

It seems Java programs that wish to support proxy authentication need to do this manually (and I was able to do this using the code on the linked page).

我已将此问题(和修复程序)提交给 Gradle 问题跟踪器.提出的问题 GRADLE-1556 在 1.0-milestone-8(2012 年 2 月)中得到解决

I submitted this issue (and a fix) to the Gradle issue tracker. Raised issue GRADLE-1556 was resolved in 1.0-milestone-8 (Feb 2012)

这篇关于Gradle 代理配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆