1、安装java
(1)下载解压jdk包
从官网下载jdk包 jdk-8u291-linux-x64.tar.gz,解压到自定义目录(如/usr/local/java/)后配置/etc/profile
scp C:\Users\xxxx\Desktop\jdk-8u291-linux-x64.tar.gz root@47.100.94.130:/root
mkdir /usr/local/java
tar -C /usr/local/java/ -zxvf jdk-8u291-linux-x64.tar.gz
vi /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_291
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
source /etc/profile
(2)查看java版本
输出版本信息即可
java -version
echo $JAVA_HOME
2、安装jenkins
(1)下载安装
sudo wget -O /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo --no-check-certificate
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum upgrade
sudo yum install jenkins
(2)Start Jenkins
sudo systemctl daemon-reload
sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins
Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2018-11-13 16:19:01 +03; 4min 57s ago
###若启动不了则尝试
1> 查看当前Java的环境变量 echo $JAVA_HOME
/usr/local/java/jdk1.8.0_291
2> 复制Java的环境变量地址, 编辑/etc/init.d/jenkins文件, 指定位置添加该地址, 后缀附上/bin/java
vim /etc/init.d/jenkins
/usr/local/java/jdk1.8.0_291/bin/java
candidates="
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-11.0/bin/java
/usr/lib/jvm/jre-11.0/bin/java
/usr/lib/jvm/java-11-openjdk-amd64
/usr/bin/java
/usr/local/java/jdk1.8.0_291/bin/java
"
3>修改后重启jenkins服务, 问题解决
systemctl daemon-reload
systemctl start jenkins
systemctl status jenkins
3、访问jenkins
1.访问ip:端口(8080)
cd /var/lib/jenkins/secrets/
cat initialAdminPassword
2.输入密钥下一步
3.默认选择推荐插件,直接下一步
5.输入账号密码下一步默认地址跳过后进入首页
4、插件中心
- Pipeline Utility Steps
- SSH Agent Plugin