搭建Jenkins简单流程
**思路:
1.搭建Jenkins需要的环境
2.选择安装Jenkins的方式
流程如下:
环境(git、maven、java)
jdk安装: 提前把jdk包下载好再上传 /usr/local
rpm -qa |grep openjdk
rpm -e --nodeps 删除自带的jdk包
(wget -O /usr/local/jdk-8u191-linux-x64.tar.gz http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u231-linux-x64.tar.gz )(wget 方式下载默认是不接受协议,故不采取)
cd /usr/local
tar -xvf jdk-8u231-linux-x64.tar.gz
vi /etc/profile
export JAVA_HOME= /usr/local/jdk1.8.0_231
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin
source /etc/profile
maven安装:(mvn -v 查看版本)
wget -O /usr/local/apache-maven-3.6.1-bin.tar.gz http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
cd /usr/local
tar -zxvf apache-maven-3.6.1-bin.tar.gz
vi /etc/profile
export MAVEN_HOME=/usr/local/apache-maven-3.6.1
export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
source /etc/profile
git安装
yum install -y git (git --version)查看版本
jenkins安装(选择yum安装)
cd /etc/yum.repos.d/
wget http://pkg.jenkins.io/redhat/jenkins.repo
rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
yum install -y jenkins
systemctl start jenkins
最后通过打开浏览器输入ip:8080进行安装
启动jenkins报错:
Starting Jenkins bash: /usr/bin/java: No such file or directory
解决方法:
vim /etc/init.d/jenkins
在此处加入
candidates="
/setup/tools/jdk1.8.0_144/bin/java #此处为加入的java路径
vim /etc/sysconfig/jenkins
do
[ -x "$JENKINS_JAVA_CMD" ] && break
JENKINS_JAVA_CMD="$candidate" #此处为$candidate
done
systemctl daemon-reload
systemctl start Jenkins