Deploy the open source continuous integration tool Jenkins under CentOS7

Deploy the open source continuous integration tool Jenkins under CentOS7

Jenkins: The most popular open source free continuous integration tool: java language development, used to monitor continuous repetitive work, including: continuous software version release/test project, monitoring external call execution work.

Jenkins is an open source, extensible continuous integration, delivery, deployment (software/code compilation, packaging, deployment) web-based interface platform, originated from Hudson (Hudson is commercial), Jenkins is written in Java language, It runs in popular servlet containers such as Tomcat, or it can run independently. Usually used in conjunction with version management tools (SCM) and build tools. Commonly used version control tools include SVN, GIT, and build tools include Maven, Ant, and Gradle

The characteristics of Jenkins are shown in the figure below

1、 Easy to install

Only one java -jar jenkins.war, after downloading the file from the official website, run it directly, without additional installation, and without installing a database;

2、 Easy configuration

Provide a friendly GUI configuration interface;

3、 Change support

Jenkins can obtain and generate a code update list from the code repository (Subversion/CVS) and output it to the compilation output information

4、 Permalink

Users access Jenkins through the web, and the link addresses of these web pages are permanent link addresses, so you can directly use the link in various documents

5、 E-Mail/RSS/IM

When an integration is completed, these tools can tell you the result of the integration in real time

6、 Distributed Construction

Jenkins can distribute work such as integrated construction to multiple computers to complete;

7、 testing report

JUnit/TestNG test report: It is to provide detailed test report function in the form of charts and other forms;

8、 Third Party Plugins

Make Jenkins become more and more powerful;

The following describes the deployment of the open source continuous integration tool Jenkins under CentOS7

1、 Yum source configuration

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo
yum clean all
yum makecache

2、 Install openjdk-1.8 in yum way

yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel

3、 Determine the real path of java and configure JDK environment variables

which java
ll /usr/bin/java
ll /etc/alternatives/java

You can see that the real path of java is /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64/jre/bin/java ​

vi /etc/profile.d/java8.sh
Add the following content
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
cat /etc/profile.d/java8.sh
# source to make it effective
source /etc/profile.d/java8.sh

If you have other JDK environment installed, you can use the following command to switch the default java environment

alternatives --config java

4、 Install jenkins.repo

Download jenkins.repo from the official website, then import the key with rpm --import

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

Since the yum source of jenkins is abroad, yum installation is too slow, you can download the rpm to the local first, and then yum localinstall can install it locally, saving time

yum localinstall jenkins-2.222.4-1.1.noarch.rpm

5、 Modify the default path of jenkins

vi /etc/sysconfig/jenkins
JENKINS_HOME line
change into
JENKINS_HOME="/data/jenkins"
create/data/jenkins directory
mkdir /data/jenkins
Modify the owner of the directory
chown jenkins /data/jenkins

6、 Start Jenkins service

systemctl enable jenkins
systemctl start jenkins
Jenkins default port 8080, of course you can modify it yourself
netstat -anp | grep 8080

7、 In response to the situation that Please wait while Jenkins is getting ready to work

Handling method

cd /data/jenkins/
cp hudson.model.UpdateCenter.xml hudson.model.UpdateCenter.xml_bak
vi hudson.model.UpdateCenter.xml
Was originally
<? xml version='1.1' encoding='UTF-8'?><sites><site><id>default</id><url>https://updates.jenkins.io/update-center.json</url></site></sites>

Replace with the following
<? xml version='1.1' encoding='UTF-8'?><sites><site><id>default</id><url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url></site></sites>

Then systemctl restart jenkins restarts the service

8、 Unlock jenkins

cat /data/jenkins/secrets/initialAdminPassword

9、 Jenkins newbie entry configuration

10、 Configure maven

cd /data/
wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
tar -zxvf apache-maven-3.6.3-bin.tar.gz
mv apache-maven-3.6.3 maven
vi /etc/profile.d/maven.sh
cat /etc/profile.d/maven.sh
export MAVEN_HOME=/data/maven
export PATH=$PATH:$MAVEN_HOME/bin
source /etc/profile.d/maven.sh

11、 Jenkins global tool configuration

Recommended Posts

Deploy the open source continuous integration tool Jenkins under CentOS7
Deploy Graylog open source log management system under CentOS7
Deploy GitBook under CentOS7
Deploy JDK+Tomcat8 under CentOS
Compile and install the open source EDA tool-Surelog on CentOS8
Installation under centos6.9 of jenkins learning
Deploy and optimize Tomcat under Centos
Install the latest OpenCV4.3 under Centos8
Compile FFMPEG source code under CentOS7
CentOS6 installs the code detection tool sonarsource
The fourth installment of Zabbix under CentOs7