简体   繁体   English

在Jenkins上通过Java Web Start启动从属代理时出现问题

[英]Problems launching the slave agent via Java Web Start on Jenkins

We have recently upgraded Jenkins to the latest verion. 我们最近将Jenkins升级到最新版本。

and since then ive not been able to launch the slaves via Java WebStart through the command line everytime I try to launch it I get "Unable to Launch the application" error 从那时起,每当我尝试启动它时,我都无法通过命令行通过Java WebStart启动从属设备我得到“无法启动应用程序”错误

with this in the details panel 在详细信息面板中使用此功能

CouldNotLoadArgumentException[ Could not load file/URL specified: http://MyServer:8080/computer/Slave1/slave-agent.jnlp]
    at com.sun.javaws.Main.launchApp(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main.access$000(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

When try browsing to the Jenkins site and lunching it from there IT WORKS however if you then restart the box then the command line on the start up fails to do the job. 当尝试浏览Jenkins站点并从那里进行午餐时,IT WORKS然后如果您再重新启动该框,则启动时的命令行无法完成该任务。

This is the command I am trying to run from the slave 这是我试图从奴隶运行的命令

cd "C:\Program Files (x86)\Java\jre7\bin"
javaws http://MyServer:8080/computer/Slave1/slave-agent.jnlp

The problem is that this used to work. 问题是这曾经奏效。 I have also tried updating to the latest version of Java but no luck, 我也尝试更新到最新版本的Java,但没有运气,

Any Idea anyone? 任何想法有人吗?

Supposedly, due in most part to posts on the Jenkins forums, this new behavior is due to a fix for a security issue: https://wiki.jenkins-ci.org/display/SECURITY/Jenkins+Security+Advisory+2013-01-04 据推测,大部分由于Jenkins论坛上的帖子,这种新行为是由于修复了一个安全问题: https//wiki.jenkins-ci.org/display/SECURITY/Jenkins+Security+Advisory+2013- 01-04

Two solutions seem to be coming up: 两种解决方案似乎即将出现:

  1. Download the JNLP file (via browser, wget, curl, whatever) then run locally - may require extra parameters. 下载JNLP文件(通过浏览器,wget,curl等)然后在本地运行 - 可能需要额外的参数。
  2. Go to Manage Jenkins -> Configure Global Security, and under Project-based Matrix Authorization Strategy, enable “connect” in the “slave” section, for user “Anonymous”. 转到管理Jenkins - >配置全局安全性,在基于项目的矩阵授权策略下,在“从属”部分中为用户“匿名”启用“连接”。 This would leave you open to attack where someone emulates a slave (but in my case, on a private work network - that's not an issue.) 如果某人模仿奴隶(但在我的情况下,在私人工作网络上 - 那不是问题,这会让你开放攻击。)

If you want to leave the JNLP file on the master, and you don't want to open the security hole for Anonymous users to connect as a slave, edit the jenkins-slave.xml file to add the -jnlpCredentials option along with the -jnlpUrl option: 如果要将JNLP文件保留在主服务器上,并且您不想打开匿名用户作为从服务器连接的安全漏洞,请编辑jenkins-slave.xml文件以添加-jnlpCredentials选项以及 - jnlpUrl选项:

-jnlpCredentials {user}:{apiKey}

where: 哪里:
user is the username in Jenkins' account database user是Jenkins帐户数据库中的用户名
apiKey is the user's API key (note this is NOT the user's password) apiKey是用户的API密钥(注意这不是用户的密码)

To get the API key for the user, go into: 要获取用户的API密钥,请进入:

http://SERVER/user/USER/configure

and click the button to show that user's API key. 然后单击按钮以显示该用户的API密钥。

For me, I had to make sure I had the "anonymous" connect set in jenkins matrix permissions AND I had to hack the JNLP file that is sent down from master. 对我来说,我必须确保我在jenkins矩阵权限中拥有“匿名”连接集,并且我不得不破解从master发送的JNLP文件。

I would say this is bug in Jenkins in 2.19.2. 我会说这是詹金斯在2.19.2中的错误。 Basically, in the JNLP file that is pulled down from the server the tunneling argument that contains the master's ip and port gets replaced with the slave ip-addr only. 基本上,在从服务器下拉的JNLP文件中,包含主服务器的ip和端口的隧道参数仅被替换为slave ip-addr。

See the code for the engine.java, [line #308] which is where the exception is thrown from: 请参阅engine.java的代码,[line#308],它是抛出异常的地方:

https://searchcode.com/codesearch/view/65603521/ https://searchcode.com/codesearch/view/65603521/

Exception looks like: 例外情况如下: 在此输入图像描述

Originally my JNLP file looked like: 最初我的JNLP文件看起来像:

<jnlp codebase="http://jenkins-master-ip-addr:8080/computer/Node1/" spec="1.0+">
<information>
    <title>Agent for Node1</title>
    <vendor>Jenkins project</vendor>
    <homepage href="https://jenkins-ci.org/"/>
</information>
<security>
    <all-permissions/>
</security>
<resources>
    <j2se version="1.7+"/>
    <jar href="http://jenkins-master-ip-addr:8080/jnlpJars/remoting.jar"/>
    <property name="hudson.showWindowsServiceInstallLink" value="true"/>
</resources>
<application-desc main-class="hudson.remoting.jnlp.Main">

    <argument>b16fdf4388d98e4be6910218cfb5a9b5fa999bcd8dec90264e525171a3b02fce</argument>
    <argument>Node1</argument>

    <argument>-tunnel</argument>
    <argument>jenkins-slave-ip-addr</argument>

    <argument>-url</argument>
    <argument>http://jenkins-master-ip-addr:8080/</argument>

</application-desc>

The problem is the "-tunnel" arg above. 问题是上面的“-tunnel”arg。 It contains the SLAVE machine's ip-addr only. 它仅包含SLAVE机器的ip-addr。 CHANGING this to the MASTER machine's ip-add AND PORT, fixed it! 将此更改为MASTER机器的ip-add AND PORT,修复它! Below: 下面:

    <argument>-tunnel</argument>
    <argument>jenkins-master-ip-addr:9080</argument>

检查命令行中的Slave1名称和jenkins节点defenition是否相同。它应该是jenkins节点中的Slave1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM