一、环境安装
1. Maven 点击下载地址
- 配置阿里镜像 修改 Maven > config > setting.xml
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
2. Git 安装
yum install git
3. Node 点击下载地址
- 解压
tar -xvf node-v12.18.3-linux-x64.tar.xz
- 创建软连接
ln -s /opt/config/node/bin/npm /usr/local/bin/
ln -s /opt/config/node/bin/node /usr/local/bin/
- 安装 yarn
npm install -g yarn
- 创建yarn 软连接
ln -s /opt/config/node/bin/yarn /usr/local/bin/
二、启动jenkin
docker run -u root -d
--name jenkins
-p 8080:8080
-p 50000:50000
-v /opt/config/jenkins/:/var/jenkins_home/
-v /opt:/opt
-v /var/run/docker.sock:/var/run/docker.sock
-e JENKINS_OPTS="--prefix=/jenkins"
-e JENKINS_ARGS="--prefix=/jenkins"
jenkins/jenkins:lts
下载docker-compose
- 进入容器:
docker exec -it jenkins /bin/bash
- 下载 docker-compose
curl -L "https://get.daocloud.io/docker/compose/releases/download/1.25.0-rc2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- 授权
chmod 777 /usr/local/bin/docker-compose
三、相关问题
1、Jenkins 导致硬盘文件多大
查看磁盘占用,找出jenkins占用磁盘原因,发现是是
modules
过大
du --max-depth=1 -h /opt/config/jenkins
创建自动清理程序 sh 文件、删除1天前的 modules
#!/bin/bash
cd /opt/config/jenkins/jobs
echo ‘+————————–开始删除1天前的modules’
files=`find */modules/* -mtime +1 -type d`
deletelog=`find */modules/* -mtime +1 -type d | xargs ls -dlh|sort|xargs|sed "s/drwxr/\n\rdrwxr/g"`
filelog=`find */modules/* -mtime +1 -type d | xargs du -h –max-depth=1`
if [ ! "$files" = "" ]
then
echo ‘+————————–即将删除的文件:’
echo ${deletelog}
echo -e "${filelog} \n"
rm -rf ${files}
else
echo ‘+————————–没有文件要删除’
fi
echo ‘+————————–删除文件执行结束’
每日执行清理
- 开启编辑 crontab
crontab -e
- 添加每日6点执行清理文件
0 6 * * * /opt/config/jenkins-clear.sh
- 查看是否生效
crontab -l