Jenkins automation tutorial: installing Jenkins under Linux

Posted by dreglo on Tue, 15 Feb 2022 08:02:44 +0100

Installing Jenkins in Linux Environment

First, you must install the java runtime environment before installing Jenkins

Download JDK

After entering the page, download the 64 bit package, jdk-8u181-linux-x64 tar. GZ and jdk-8u181-linux-x64 Rpm is OK. The following will introduce the installation methods of the two packages respectively. Select one of them for installation.

Preparation before installation

Check whether jdk is installed in the system first

[root@VM-12-5-centos ~]# java -version
-bash: java:Command not found

If the system prompts, this is not installed

[root@VM-12-5-centos ~]# java -version
java version "1.8.0_311"
Java(TM) SE Runtime Environment (build 1.8.0_311-b11)
Java HotSpot(TM) Client VM (build 25.311-b11, mixed mode)

If the above version information is displayed, it indicates that it has been installed. You can directly use the JDK of the system without installing it yourself

Installation method of tar package

First, upload the downloaded tar package to the specified directory of the server, such as / usr/local directory, and use the following command to unzip it

[root@VM-12-5-centos ~]# tar -zxvf jdk-8u311-linux-i586.tar.gz

Modify the configuration file, configure the environment variables, and enter on the command line:

[root@VM-12-5-centos local]# vi /etc/profile
# Add the following at the bottom of the file, where JAVA_HOME is the jdk decompression directory, which can be modified according to the actual situation
export JAVA_HOME=/usr/local/java
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JRE_HOME=$JAVA_HOME/jre

After the configuration file is edited, we use the command to make the configuration file effective

[root@VM-12-5-centos local]# source /etc/profile
# Then we check the java version with the following command
[root@VM-12-5-centos local]# java -version
 The following errors are prompted because of the lack of our system environment
-bash: /usr/local/jdk1.8/bin/java: /lib/ bad ELF interpreter: No such file or directory
# We run the following command
[root@VM-12-5-centos local]# sudo yum install glibc.i686
# Run the view version command again
[root@VM-12-5-centos ~]# java -version
java version "1.8.0_311"
Java(TM) SE Runtime Environment (build 1.8.0_311-b11)
Java HotSpot(TM) Client VM (build 25.311-b11, mixed mode)

As above, our jdk is configured

1. Download Jenkins

Download linux jenkins, official website address:
This is a foreign website, so the access is very slow. You can download it through my baidu cloud, Baidu cloud Extraction code: nga1
After downloading, put the downloaded package on the server and run the decompression command

rpm -ivh jenkins-2.174-1.1.noarch.rpm

After successful decompression, check the Jenkins installation directory

whereis jenkins

Switch to the Jenkins installation directory and start Jenkins

sudo service jenkins start

At this time, we can see the error message

This is because we did not specify the Java installation directory
In / etc / ini Under the D / Jenkins file, configure the installation path of Java

# Search usable Java as /usr/bin/java might not point to minimal version required by Jenkins.
# see
#java installation path

When Jenkins is finished, let's start it

The startup is successful. Next, let's visit Jenkins on the page http://IP:8080 that will do

It can be accessed normally, but we can see another error:
-AWT is not configured correctly on this server. Maybe you need to run the container with "- Djava.awt.headless = true"? See also:
The reason for the problem is that the general os is installed with 64 bits, so the libgcc package is installed by default. However, java generally uses 32-bit packages, so there will be the above problems ( provided by the system is 64 bit, not 32-bit required for java startup). Just install a 32-bit package.
Execute the following script

sudo yum install libgcc.i686 --setopt=protected_multilib=false

The success is as follows

Is this ok [y/d/N]: y
Downloading packages:
libgcc-4.8.5-44.el7.i686.rpm                                                                          | 111 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libgcc-4.8.5-44.el7.i686                                                                                  1/1 
  Verifying  : libgcc-4.8.5-44.el7.i686                                                                                  1/1 

  libgcc.i686 0:4.8.5-44.el7                                                                                                 


It's time for us to restart Jenkins, okay

Topics: Linux jenkins