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 -->
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的地址,例如這裡:
點選進入對應的該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的地址問題。
如果直接launch出錯,我們就不要在點選launch按鈕起啟動了,採用命令列去啟動也是一樣的,命令列的命令上面已經給出了:
命令1: javawshttp://jenkins.meilishuo.com/computer/irshost12.tc.com.com/slave-agent.jnlp
如果上面的正常的話,過一會幾分鐘後,這個介面應該就會變成下面的介面,就是多了一個File選單,下拉這個File選單就有一個選項他會提示你是否想設定為一個自啟動的服務。可能將當前的slave設定成一個服務,每次機器重啟的時候都自動啟動slave服務,這樣就不能每次都去啟動這個slave agent了。
# Master 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頁面可以看到怎樣通過命令建立連線