00:文章简介
介绍Jenkins安装及初始化。
01:安装Jenkins
1.1:apt安装
官方文档 https://www.jenkins.io/download/
# 前置条件java
apt install openjdk-8-jdk
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
echo "JENKINS_USER=root" >> /etc/default/jenkins
systemctl restart jenkins
# 让jenkins以root身份运行,否则后面的任务会出现权限问题
1.2:dpkg安装
#
mkdir /data/{server,softs}/jenkins
cd /data/softs/jenkins
wget http://mirrors.jenkins.io/war-stable/latest/jenkins.war
cp jenkins.war /data/softs/server/jenkins/
# 配置服务脚本
# vim /lib/systemd/system/jenkins.service
[Unit]
Description= jenkins server project
[Service]
User=root
ExecStart=/data/server/java/bin/java -jar /data/server/jenkins/jenkins.war &
ExecStop=/bin/kill -TERM ${MAINPID}
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
# 重启服务
systemctl daemon-reload
systemctl start jenkins.service
systemctl status jenkins.service
# 安装后的家目录是 ~/.jenkins
1.3:docker安装(未测试)
docker pull jenkins/jenkins
docker pull docker:dind
docker network create jenkins
docker run --name jenkins-docker --rm --detach --privileged --network jenkins \
--network-alias docker --env DOCKER_TLS_CERTDIR=/certs \
--volume jenkins-docker-certs:/certs/client --volume jenkinsdata:/var/jenkins_home \
--publish 2376:2376 docker:dind --storage-driver overlay2
02:初始化
2.1:访问默认站点
netstat -nutlp | grep java # 8080端口
# 浏览器访问8080端口
2.2:选择插件安装
点击上面的【无】
评论区