Jenkins Quick Start - Part 5 - Setting Up a Build Slave

2018年04月27日


SSH to Jenkins Master server. From there, SSH to Jenkins slave node.
[root@master ~]# su - jenkins

[root@master ~]# ssh 10.0.0.x

[jenkins@slave ~]$ exit

[jenkins@slave ~]$ sudo yum install -y git

[jenkins@slave ~]$ java
-bash: java: command not found

[jenkins@slave ~]$ java -version
-bash: java: command not found

[jenkins@slave ~]$ pwd
/home/jenkins

[jenkins@slave ~]$ mkdir jenkins_slave  # remote workspace

[jenkins@slave ~]$ sudo yum install java-11-openjdk-devel -y
[jenkins@Slave ~]$ sudo yum install -y java-1.8.0-openjdk  # 需要先安装java-1.8.0-openjdk,否则后面不能Launch Jenkins Slave agent


Manage Jenkins
Manage Nodes and Clouds
New Node
Node name: centos-slave1
Select "Permanent Agent"

Number of executors: 4
Remote root directory: /home/jenkins/jenkins_slave
Labels: centos_slave1
Usage: Only build jobs with label expressions matching this node
Launch method: Launch agents via SSH
Host: 10.0.0.x  # private IP of the Jenkins slave node
Credentials, Add, Jenkins
Kind: SSH Username with private key
Username: jenkins
Private Key: From the Jenkins master node ~/.ssh /var/lib/jenkins/.ssh/id_rsa
ID: JenkinsUserKey
Description: The connection for our slave node and its credentials  # 填写description是有用的,填写了description以后,Credentials下拉列表会将description的内容备注在括号里,在有同名username的时候可以以此作为区分


点击输入用户名和密码的链接,输入登录Oracle的用户名和密码
*

*

*

*
补充
[root@slave tools]# cd /usr/local/
[root@slave tools]# mkdir -p tools
[root@slave tools]# cd tools/
[root@slave tools]# wget --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie;" http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz
[root@slave tools]# tar -vxzf jdk-8u171-linux-x64.tar.gz  # 进行解压,得到jdk1.8.0_171文件夹
[root@slave tools]# ll
total 252276
drwxr-xr-x 8 10 143 4096 Mar 29 08:18 jdk1.8.0_171
-rw-r--r-- 1 root root 5307 Mar 21 2012 jdk-7u71-linux-x64.rpm
-rw-r--r-- 1 root root 190890122 Apr 4 02:05 jdk-8u171-linux-x64.tar.gz
*
[root@slave tools]# vim /etc/profile  # 在文件最后添加
export JAVA_HOME=/usr/local/tools/jdk1.8.0_171  # 这里根据自己的jdk包所在的位置进行自行更改
export PATH=$JAVA_HOME/bin:$PATH
*
[root@slave tools]# . /etc/profile
测试
[root@slave tools]# java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
*
出现以上字样,则表明配置成功!
*
[root@slave ~]# mkdir -p /usr/bin/java
[root@slave ~]# cd /usr/bin/java
[root@slave java]# wget --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie;" http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz
[root@slave java]# tar -vxzf jdk-8u171-linux-x64.tar.gz  # 进行解压,得到jdk1.8.0_171文件夹

[root@slave java]# ll
total 186424
drwxr-xr-x 8 10 143 4096 Mar 29 08:18 jdk1.8.0_171
-rw-r--r-- 1 root root 190890122 Apr 4 02:05 jdk-8u171-linux-x64.tar.gz
[root@slave java]# vim /etc/profile  # 在文件最后添加
*
export JAVA_HOME=/usr/bin/java/jdk1.8.0_171  # 这里根据自己的jdk包所在的位置进行自行更改
export PATH=$JAVA_HOME/bin:$PATH
*

*
[root@slave ~]# mkdir -p /usr/java
[root@slave bin]# wget --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie;" http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz
[root@slave bin]# tar -vxzf jdk-8u171-linux-x64.tar.gz  # 进行解压,得到jdk1.8.0_171文件夹
[root@slave bin]# vim /etc/profile  # 在文件最后添加
*
export JAVA_HOME=/usr/bin/jdk1.8.0_171  # 这里根据自己的jdk包所在的位置进行自行更改
export PATH=$JAVA_HOME/bin:$PATH
*
[root@slave bin]# . /etc/profile

*
参考:https://blog.csdn.net/hg_harvey/article/details/73824084

[root@slave usr]# yum list | grep java-1.8.0-openjdk
*
[root@slave usr]# yum install -y java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64

*

Category: Jenkins Tags: public

Upvote


Downvote