1、环境安装
(1)JDK安装:sudo apt-get install openjdk-7-jdk
(2)maven2安装:sudo apt-get install maven2
注:maven安装好之后 ,要注意在特殊情况下替换成自己的settings.xml。位置在/etc/maven2/settings.xml
(3)ssh安装:sudo apt-get install openssh-client(系统默认应该是安装好的)
sudo apt-get install openssh-server
(4)在master节点上安装jenkins服务(以ubuntu为例)
wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
sudo apt-get update
sudo apt-get install jenkins
启动web管理页面:http://localhost:8080
2、在jenkins上创建节点,如下图
3、将slave连接到master,通过ssh连接,在master执行以下命令
zhaozh@ubuntu:~$ssh zzh@172.21.101.130
zzh@172.21.101.130'spassword:
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux3.13.0-32-generic x86_64)
*Documentation: https://help.ubuntu.com/
522 packages can be updated.
239 updates are security updates.
Last login: Wed Nov 11 17:44:04 2015 from172.21.101.132
zzh@ubuntu:~$wget http://72.21.101.132:8080/jnlpJars/slave.jar
--2015-11-11 17:48:01-- http://172.21.101.132:8080/jnlpJars/slave.jar
Connecting to 172.21.101.132:8080...connected.
HTTP request sent, awaiting response... 200OK
Length: 489023 (478K)[application/java-archive]
Saving to: ‘slave.jar’
100%[======================================>]489,023 --.-K/s in 0.01s
2015-11-11 17:48:01 (37.4 MB/s) -‘slave.jar’ saved [489023/489023]
zzh@ubuntu:~$java -jar slave.jar -jnlpUrlhttp://172.21.101.132:8080/computer/DBServerNode/slave-agent.jnlp
Nov 11, 2015 5:48:12 PMhudson.remoting.jnlp.Main createEngine
INFO: Setting up slave: CoinServerNode
Nov 11, 2015 5:48:12 PMhudson.remoting.jnlp.Main$CuiListener <init>
INFO: Jenkins agent is running in headlessmode.
Nov 11, 2015 5:48:12 PMhudson.remoting.jnlp.Main$CuiListener status
INFO: Locating server among[http://localhost:8080/, http://172.21.101.132:8080/]
Nov 11, 2015 5:48:12 PMhudson.remoting.jnlp.Main$CuiListener status
INFO: Handshaking
Nov 11, 2015 5:48:12 PMhudson.remoting.jnlp.Main$CuiListener status
INFO: Connecting to 172.21.101.132:34626
Nov 11, 2015 5:48:12 PMhudson.remoting.jnlp.Main$CuiListener status
INFO: Trying protocol: JNLP2-connect
Nov 11, 2015 5:48:12 PMhudson.remoting.jnlp.Main$CuiListener status
INFO: Connected
4、创建maven2工程,如下图
5、执行,build now即可完成