我们在连接上有一个 Subversion 存储库https
。我可以在本地连接到它(无需代理):
$ svn ls --username=qazwart --password=swordfish \
https://svn.corpwad.com/repos/potzrebie/branches/build-test
build.xml
src
...
现在,我登录到需要代理的构建服务器:
$ ssh [email protected]
Last login: Thu Aug 14 09:22:48 2014 from qazwart.corpwad.net
$ export | egrep "JENKINS|_proxy"
declare -x JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dhttps.proxyHost=proxy.corpwad.net -Dhttp.proxyHost=proxy.corpwad.net -Dhttp.proxyPort=3128 -Dhttps.proxyPort=3128 -Dhttp.auth.preference=Basic"
declare -x http_proxy="http://proxy.corpwad.net:3128"
declare -x https_proxy="http://proxy.corpwad.net:3128"
如您所见,我已经JENKINS_JAVA_OPTOPNS
设置了我的代理,并且已经https_proxy
设置好了。代理不需要登录,但我们的 Subversion 存储库需要登录:
咱们试试吧wget
:
$ wget -O - --user=qazwart --password=swordfish https://svn.corpwad.com/repos/potzrebie/branches/build-test
--2014-08-14 09:54:09-- https://svn.corpwad.com/repos/potzrebie/branches/build-test
Resolving proxy.ilcb.tcprod.local... 10.80.12.90
Connecting to proxy.corpwad.net|10.80.12.90|:3128... connected.
Proxy request sent, awaiting response... 401 Authorization Required
Connecting to proxy.corpwad.net|10.80.12.90|:3128... connected.
Proxy request sent, awaiting response... 301 Moved Permanently
Location: https://svn.corpwad.com/repos/potzrebie/branches/build-test [following]
--2014-08-14 09:54:10-- https://svn.corpwad.com/repos/potzrebie/branches/build-test
Connecting to proxy.ilcb.tcprod.local|10.80.12.90|:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 1130 (1.1K) [text/html]
Saving to: “STDOUT”
0% [ ] 0 --.-K/s <html><head><title> potzrebie - Revision 1937: /branches/build-test</title></head>
<body>
<h2> potzrebie - Revision 1937: /branches/build-test</h2>
<ul>
<li><a href="../">..</a></li>
<li><a href="build.xml">build.xml</a></li>
...
</ul>
100%[==============================================================================>] 1,130 --.-K/s in 0s
2014-08-14 09:54:10 (51.6 MB/s) - written to stdout [1130/1130]
$
好的,我可以通过wget
连接到我的存储库。这意味着我确实可以从我们的构建服务器通过网络连接到我们的存储库。不幸的是,我的系统没有用于测试的 Subversion 命令行客户端。我必须要求我们的 IT 部门为其安装 RPM,但现在我无法测试。幸运的是,Jenkins 不需要命令行客户端,因为它使用svn工具包.:我创建一个 Jenkins Freestyle 作业,选择颠覆作为我的存储库,并在存储库 URL字段,我会输入https://svn.corpwad.com/repos/potzrebie/branches/build-test
。我设置了一个全球使用用户qazwart
和密码登录swordfish
。但是,当仍然在构建配置屏幕上时,我得到了以下信息:
Unable to access https://svn.corpwar.com/repos/potzrebie/branches/build-test : svn: E175002: OPTIONS /repos/potzrebie/branches/build-test failed
org.tmatesoft.svn.core.SVNException: svn: E175002: OPTIONS /repos/potzrebie/branches/build-test failed
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:388)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:373)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:361)
at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.performHttpRequest(DAVConnection.java:707)
....
Caused by: svn: E175002: OPTIONS /repos/potzrebie/branches/build-test failed
at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:208)
at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:154)
at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:97)
... 88 more
Caused by: org.tmatesoft.svn.core.SVNException: svn: E175002: OPTIONS request failed on '/repos/potzrebie/branches/build-test'
svn: E175002: connection refused by the server
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:64)
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:51)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection._request(HTTPConnection.java:777)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:382)
... 87 more
Caused by: svn: E175002: OPTIONS request failed on '/repos/potzrebie/branches/build-test'
at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:208)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection._request(HTTPConnection.java:775)
... 88 more
Caused by: svn: E175002: connection refused by the server
at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:208)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection._request(HTTPConnection.java:520)
... 88 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
我感觉我缺少了一个小步骤,但我无法弄清楚。
答案1
发现问题了。虽然我设置了JENKINS_JAVA_OPTIONS
,但 Tomcat 本身启动时并没有设置。我进入$CATALINA_BASE/bin/setenv.sh
并添加了:
CATALINA_OPTS="$CATALINA_OPTS $JENKINS_JAVA_OPTIONS -DJENKINS_HOME=...
这将设置 Java 启动时所需的属性。
答案2
我找到了一种在 Windows 环境下将这些值导入 Java 的替代方法,该方法对我有用。
在下面C:\Program Files (x86)\Jenkins\jenkins.xml
我编辑了输入到 java 中的行
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>
到
<arguments>-Xrs -Xmx256m -Djava.awt.headless=true -Dhttp.proxyHost=proxy.myproxy.com Dhttp.proxyPort=99999 -Dhttp.auth.preference=Basic -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>
关键插入是-Dhttp.proxyHost=proxy.myproxy.com Dhttp.proxyPort=99999 -Dhttp.auth.preference=Basic
Jenkins.xml 文件本身让我去搜索这个jre\bin\java
可执行文件可能在哪里,这样我就可以对其进行探索,以更好地了解其命令行参数的作用。我发现,在C:\Program Files (x86)\Java\jre6\bin>java
具有以下形式的参数下-D<name>=<value>
,我需要设置一系列参数,以便将代理设置正确传达给 Java。
我费了好大劲才让 SVN 设置在代理服务器后面工作,这非常令人困惑,因为 Jenkins 本身可以连接到代理,正如我为其启用的代理设置所指示的那样,该设置已通过测试。这非常不直观,需要进一步的设置才能建立代理设置。
为了帮助其他遇到此问题的人,我最初遇到的错误如下:
Checking out a fresh workspace because there's no workspace at C:\SVNXXX\JenkinsWorkspace
Cleaning local Directory .
Checking out http://xxxxxxxxxx/trunk at revision '2016-03-18T16:12:17.711 -0700'
ERROR: Failed to check out http://xxxxxxxxxxxx/trunk
org.tmatesoft.svn.core.SVNException: svn: E175002: connection refused by the server
svn: E175002: OPTIONS request failed on 'xxxxxxxxx/trunk'