jenkins installation (Linux)

Please be careful to install the latest version of jenkins

The blogger tried jenkins-2.401-1.1.noarch, but the installation failed, so he changed it to 344. Readers are advised to install the latest version carefully.

1. Introduction to Jenkins

Jenkins is an open source automation server for automating building, testing, and deploying software projects. It provides an easy-to-use continuous integration and continuous delivery (CI/CD) solution that helps software teams deliver high-quality software faster. Jenkins can be integrated with many version control systems, build tools, and testing frameworks, such as Git, Subversion, Maven, and JUnit. In addition, Jenkins also has a rich plug-in ecosystem that can extend its functionality to meet different needs.

With Jenkins, you can set up regular builds and tests of your code, and report the results back to the right people. If anything goes wrong, Jenkins will notify you and provide detailed logging so you can easily diagnose the problem and take appropriate action. Jenkins can also automatically deploy code to various environments, thereby speeding up the software delivery process and reducing error rates.

1.1 Jenkins usage scenarios

Jenkins is a popular open source continuous integration and continuous delivery tool that helps software development teams automate building, testing, and deploying applications.

The following is a simple Jenkins instance:

First, you need to install Jenkins. You can download the installer from the Jenkins official website and install it according to the instructions.

Once installed, open the Jenkins console and create a new project. Select the "New Item" option, then enter a project name and select "Freestyle project".

In the project configuration page, you can set the build steps to be executed. For example, you can use the "Execute shell" build step to run a shell script or command.

Next, you need to configure a build trigger to specify when a build is triggered. For example, you can set up a build to be triggered automatically every time code is committed to a Git repository.

Finally, you can save the project configuration and start the build manually or wait for an automatic build to trigger.

With this simple Jenkins example, you can learn how to configure build steps, build triggers, and how to start a build. Jenkins has many other features and plugins to better suit your needs.

2. jenkins download

Tsinghua University jenkins mirror station
blogger downloaded jenkins-2.401-1.1.noarch.rpm

2.1 Upload to Linux

Bloggers upload to /usr/local
insert image description here

2.2 rpm install jenkins

Enter usr/local

cd /usr/local

rpm -ivh jenkins-2.401-1.1.noarch.rpm

insert image description here

2.3 Modify jenkins configuration

文件位置:/etc/sysconfig/jenkins

vim /etc/sysconfig/jenkins

insert image description here

2.3.1 Modifications

JENKINS_USER ="root”
JENKINS_PORT=“8888”

2.4 Open ports

insert image description here

2.5 start jenkins

systemctl start jenkins

2.5.1 Startup errors

insert image description here
The blogger used yum to install jdk, and found that java_home was not configured, and jenkins could not find it.

2.5.2 Add JAVA_HOME

The jdk location installed by yum:

/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.362.b08-1.el7_9.x86_64/jre/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.362.b08-1.el7_9.x86_64/bin/java

insert image description here

# 查看javahome
echo $JAVA_HOME
# 加载环境变量
source /etc/profile
# 添加环境变量
vim /etc/profile

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.362.b08-1.el7_9.x86_64
export PATH=$PATH:$JAVA_HOME/bin

insert image description here
Added successfully

2.6 jenkins configuration to add custom installation java directory

vim /etc/init.d/jenkins

insert image description here
try to start

2.7 Error

2.7.1 maven

If maven is not installed, please see the following tutorial
maven installation tutorial linux

2.7.2 git

If git is not installed, please see the following tutorial
Linux installation git (centos7)-yum

2.7.3 Certificate

If it is not successful, the certificate may not be installed, just enter the following command:

sudo yum install -y ca-certificates

wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo


rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key

Reference link: How to build a Jenkins server environment in a Linux (CentOS7) environment

or

wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.repo

rpm --import http://pkg.jenkins.io/redhat-stable/jenkins.io.key

2.7.4 Public key for jenkins-2.387.2-1.1.noarch.rpm is not installed

yum clean all

yum makecache

yum install epel-release

2.7.5 The startup port has not been modified

insert image description here

  1. Modify the jenkins.xml file
find / -name jenkins.xml

vim /usr/lib/firewalld/services/jenkins.xml

insert image description here
fail

  1. Modify the jenkins.service file
vim /usr/lib/systemd/system/jenkins.service

insert image description here
success
访问jenkins的地址为: ip+8888

2.8 Unlock jenkins to view password

Use the following command to view the password to unlock jenkins

1. cat /var/lib/jenkins/secrets/initialAdminPassword
2. systemctl status jenkins

3. Getting Started

It is not recommended to install plug-ins when logging in for the first time.
On the Getting Started page, select "Select plug-ins to install"
and then click None to skip.

3.1 Create an administrator account

Enter your user name, password, click save and finish
insert image description here

3.2 Instance configuration

After checking that the URL is ok, save and finish
insert image description here

3.3 Getting Started

Click to start using jenkins
insert image description here

4. jenkins plugin

4.1 install locale

insert image description here

4.2 Replacement source

manage jenkins -> manage plugins -> advanced

cd /var/lib/jenkins/updates

sed -i 's$http:V/updates.jenkins-ci.org/download$https://mirrors.tuna.tsinghua.edu.cn/jenkins$g'
default.json
sed -i 's$http://www.google.com$https://www.baidu.com$g' default.json

insert image description here

# 替换advanced
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/updatecenter.json

insert image description here
Click Submit
insert image description here

4.3 restart jenkins

Just restart it when jenkins is running

http://xx.xx.xx.xx:8888/restart
click yes

insert image description here

4.4 Log in to jenkins

Enter the user just now
and log in successfully

At this point, jenkins is installed

Guess you like

Origin blog.csdn.net/dwh19992018/article/details/129701978