一 git安装与部署--git的ip服务器上操作
1.安装git
yum install -y git
2.创建用户和设置密码
useradd git
passwd git
3.创建和初始化仓库
cd /home/git
mkdir repos
mkdir app.git
git --bare init /home/git/repos/app.git/
二 Jenkins安装与部署---Jenkins的ip服务器上操作
1.Jenkins的安装
(1)进入官网https://pkg.jenkins.io/redhat-stable/
操作这两条命令---自动安装jenkins
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
(2)rpm ql jenkins---查看Jenkins的安装目录
2.配置java环境
(1)登录oracle官网,注册账号(有账号不必注册直接登录)并下载jdk
https://www.oracle.com/java/technologies/javase-downloads.html
(2)安装jdk
tar -zxvf /tmp/jdk-8u162-linux-x64.tar.gz -C /usr/local/jdk/
修改/etc/profile
vi /etc/profile
添加
export JAVA_HOME=/usr/local/jdk/jdk1.8.0_162
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
重新加载/etc/profile
source profile
检查jdk版本
java -version
(3)启动Jenkins
service jenkins start
如果报错jenkins 启动时报错:Starting Jenkins bash: /usr/bin/java: No such file or directory
则vim /etc/init.d/jenkins
添加jdk路径
candidates="
/etc/alternatives/java
/usr/local/jdk/jdk1.8.0_251/bin/java---添加的java路径
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.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
"
重新启动
systemctl daemon-reload
service jenkins start
(4)获取jenkins的管理员密码
tail -f /var/lib/jenkins/jenkins.log
cat /var/lib/jenkins/secrets/initialAdminPassword