Jenkins environment installation
I used war installation before, the installation is relatively simple, that is, the corresponding plug-in of jenkins cannot be downloaded, and later found out that it is a version problem, using docker-compose installation, jenkins installation plug-in is easy to install
1. Install jdk
-
decompress jdk
-
Configure environment variables
#set java environment JAVA_HOME=/usr/local/jdk1.8.0_281 PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME PATH
2. Install maven
Download maven linux version
https://dlcdn.apache.org/maven/maven-3/3.9.3/binaries/
Upload to soft under opt under linux
Unzip to /usr/local/
tar -xvf apache-maven-3.6.3-bin.tar.gz -C /usr/local
Configure maven's warehouse location
<localRepository>/opt/maven/repo</localRepository>
Configure Ali Mirror
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
Maven configuration environment variables
Configure environment variables: configure maven environment variables under the /etc/profile file
Refresh after configuration
source /etc/profile
JAVA_HOME=/usr/local/jdk1.8.0_281
MAVEN_HOME=/usr/local/apache-maven-3.6.3
PATH=$JAVA_HOME/bin:$PATH:$MAVEN_HOME/bin
export JAVA_HOME PATH MAVEN_HOME
3. Install git
yum -y install git # 安装
git version # 安装是否成功
4. Install docker
# 1、yum 包更新到最新(时间比较久,大概5分钟左右)
sudo yum update
# 2、作用:安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# 3、 设置yum源
# 使用ustc的
sudo yum-config-manager --add-repo http://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
# 4、 安装docker;出现输入的界面都按 y(时间比较久,大概30分钟左右,ce表示社区版 ee表示企业版)
sudo yum install -y docker-ce
# 5、 查看docker版本
docker -v
5. Install docker-compose
Install
sudo curl -L "https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Installation process:
chmod +x /usr/local/bin/docker-compose set permissions, open
Check if the installation was successful:
6. Install jenkins
Install based on docker-compose
version: "3"
services:
jenkins:
image: "jenkins/jenkins:2.396-jdk11"
user: root
privileged: true
restart: always
container_name: jenkins
ports:
- 8080:8080
- 50000:50000
volumes:
- /opt/jenkins/jenkins_home:/var/jenkins_home
- /usr/local/apache-maven-3.6.3://usr/local/apache-maven-3.6.3 # 配置maven
# 让容器使用宿主的docker
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker
- /etc/docker:/etc/docker
environment:
- TZ=Asia/Shanghai
7. Start jenkins
8. Install the plug-in
1. Obtain and enter the admin account password
Enter the container and get the password
docker exec -it jenkins bash
cat /var/jenkins_home/secrets/initialAdminPassword
Different versions may be in different locations: xxx
2. Install the recommended plug-ins
Notice:
There are version and plug-in problems, and the installation cannot be successful
3. Add an administrator account and enter the Jenkins background
Create one: account: admin password 123456