<

1. Jenkins是什么? #

cicd

2.创建React项目 #

create-react-app react-cicd

3. 安装JDK #

cd /usr/local/src
wget http://upload-markdown-images.oss-cn-beijing.aliyuncs.com/jdk1.8.0_211.tar.gz
tar -xzvf jdk1.8.0_211.tar.gz 
mkdir /usr/java
cp -r /usr/local/src/jdk1.8.0_211 /usr/java
ln -s /usr/java/jdk1.8.0_211/bin/java /usr/bin/java

4. 安装jenkins #

wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum install -y jenkins

5. 安装插件 #

5. 关闭防火墙 #

systemctl stop firewalld.service
systemctl disable firewalld.service

6. 配置webhook #

liblib

webhook

7. 编写构建脚本 #

npm config set registry http://registry.npm.taobao.org/ &&
npm install &&
npm -rf build &&
npm run build 

9. 安装nginx #

vi /etc/yum.repos.d/nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
安装nginx
yum install nginx -y

10. 布署服务器 #

ssh-keygen -t rsa
ssh-copy-id 192.168.1.2
npm config set registry http://registry.npm.taobao.org/ &&
npm install &&
npm -rf build &&
npm run build 
cd build&&
tar -zcvf build.tar.gz *
cd /usr/share/nginx/html &&
tar -xzvf build.tar.gz &&
rm -rf build.tar.gz

publishssh

snedssh

11. 邮件提醒 #