jenkins配置slave

配置jenkins的slave节点

进入jenkins,系统管理,管理节点,新建节点,创建一个dumb slave。

进去其配置页面,主要说明的是launch method

选择 launch slave agents on unix machinesvia ssh

host:机器ip

credentials:授权信息(可在jenkins里配置 add credentials)

选择launchslave agent via java web start,这个方式建议在windows上使用

Fill outthe following:

1.           Set a number of executors (one ormore) as needed.

2.           Set a Remote FS Root, a home directory for themaster on the slave machine.

1.                 For a Windows slave, use something like:"C:\Jenkins\"

2.                 TODO: add details.

3.           Select the appropriate Usage setting:

1.                 For an additional worker: Utilizethis slave as much as possible 

2.                 For specialized jobs: Leave thismachine for tied jobs only

4.           Launch Method:

1.                 An easy way to control a Windows slaveis by using Launchslave agents via Java Web Start  (Recommendedfor Windows)

2.                 TODO: add steps for other methods.

5.           Availability --> Keep thisslave online as much as possible

1.                 TODO: add details for each option.

6.           Press OK.

7.           Now you need to connect your slavemachine to the master using the following steps.

1.                 Open a browser on the slavemachine and go tothe Jenkinsmaster server url (http://yourjenkinsmaster:8080).

2.                 Go to Manage Jenkins > ManageNodes, Click onthe newly created slave machine. You will need to login as someone that has the"Connect" Slave permission if you have configured global security.

3.                 Click on the Launch button tolaunch agent from browser on slave.

4.                Run the program.

5.                 Nowyou should see the Slave machine connected under Nodes.

 下面介绍另一种更简单的方式:

1,进入需要控制的远程机器上,一定要进入远程的slave机器,而不是你的master机器。输入对应的你的jenkins的地址,例如这里:

http://jenkins.meilishuo.com/computer/

点击进入对应的该slave机器的图标进入:此时可能会报一些错误,不用管。

点击图中的launch按钮,他会提示你下载该文件slave-agent.jnlp.按照提示下载该文件,并保存在本地。我们这里需要确认两个问题是否存在:

问题一,确认slave-agent.jnlp 是用javaws来运行的,而不是java.exe 或者是javaw.exe来运行,因为一般的机器默认是采用java.exe启动的。我曾经因为这个问题折腾了好久。

问题二,将slave-agent.jnlp用notepad打开后,确认其中的URL是可用的Jenkins地址。其中的配置可能是这样的:

<jnlp spec="1.0+" codebase="http://jenkins.meilishuo.com/computer/192.168.161.34/">

<information>

<title>Slave Agent for 192.168.161.34</title>

<vendor>Jenkins project</vendor>

<homepage href="https://jenkins-ci.org/"/>

</information>

<security><all-permissions/></security>

<resources><j2se version="1.5+"/><jar href="http://jenkins.meilishuo.com/jnlpJars/remoting.jar"/><property name="hudson.showWindowsServiceInstallLink" value="true"/>

</resources><application-desc main-class="hudson.remoting.jnlp.Main">

<argument>60c101541d377ad629da21b37c24cd6227edef74b97ff663c5b09e261ac2d5d6</argument><argument>irshost12.tc.tb.com</argument>

<argument>http://jenkins.meilishuo.com/</argument>

</application-desc>

</jnlp>

确认其中的url地址是上面的正确的地址,而不是localhost,因为我的jenkins部署在本地测试。所以这里就遇到了显示localhost的地址问题。

之所以说这个是因为这个是jenkins的一个bug:http://stackoverflow.com/questions/11287845/jenkins-slave-cant-get-started

如果直接launch出错,我们就不要在点击launch按钮起启动了,采用命令行去启动也是一样的,命令行的命令上面已经给出了:

命令1: javawshttp://jenkins.meilishuo.com/computer/irshost12.tc.com.com/slave-agent.jnlp

命令2: java -jar slave.jar -jnlpUrl http://jenkins.meilishuo.com/computer/192.168.161.34/slave-agent.jnlp -secret xxxxx(该字符串就在slave-agent.jnlp文件中)

如果上面的正常的话,过一会几分钟后,这个界面应该就会变成下面的界面,就是多了一个File菜单,下拉这个File菜单就有一个选项他会提示你是否想设置为一个自启动的服务。可能将当前的slave设置成一个服务,每次机器重启的时候都自动启动slave服务,这样就不能每次都去启动这个slave agent了。

#     Master Jenkins服务器端的配置细节                         

如果上面的窗口中显示Connected,可是一会有出现了Terminated的状态,那么很可能是因为你的jenkins配置权限的时候没有给匿名用户启动slave的权限:http://stackoverflow.com/questions/14277512/problems-launching-the-slave-agent-via-java-web-start-on-jenkins

Two solutions seem to becoming up:

8.  Download the JNLP file (via browser, wget, curl,whatever) then run locally - may require extra parameters.

9.  Go to Manage Jenkins -> Configure Global Security, andunder Project-based Matrix Authorization Strategy, enable “connect” in the“slave” section, for user “Anonymous”. This would leave you open to attackwhere someone emulates a slave (but in my case, on a private work network -that's not an issue.)

具体操作是进入jenkins主界面,然后进入Manage Jenkins ->Configure Global Security ,勾选其中的anonymous用户的slave部分的权限。

注:当slave没有与master建立连接时,从jenkin页面可以看到怎样通过命令建立连接

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值