“This is the fifth day of my participation in the November Gwen Challenge. See details of the event: The Last Gwen Challenge 2021”.

Jenkins is a standalone open source automation server that can be used to automate a variety of tasks related to building, testing, delivering, or deploying software.

Jenkins can be installed via the native system package, Docker, or even run independently from any machine with the Java runtime environment (JRE) installed.

Install the JDK

Viewing the JDK Version

yum search java|grep jdk
Copy the code

Install openjdk1.8

Yum install Java -- 1.8.0 comes with itsCopy the code

Check whether the installation is successful:

[root@localhost lib]# java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)
Copy the code

Configure environment variables:

vi /etc/profile
Copy the code

Add the following

Export JAVA_HOME = / usr/lib/JVM/Java -- 1.8.0 comes with its - 1.8.0.292. B10-1. El7_9. X86_64 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/binCopy the code

Install Git

Installation:

yum install -y git
Copy the code

Check whether the installation is successful:

[root@localhost lib]# git version 1.8.3.1Copy the code

Install Maven

Installation:

yum -y install maven
Copy the code

View maven version:

[root@localhost lib]# MVN -version Apache 3.0.5 (Red Hat 3.0.5-17) Maven Home: /usr/share/maven Java version: 1.8.0_292, Vendor: Red Hat, Inc. Java Home: /usr/lib/jvm/java-1.8.0-openJDK-1.8.0.292.b10-1.el7_9.x86_64 / JRE Default locale: zh_CN, platform encoding: Utf-8 OS name: "Linux ", version: "3.10.0-1062.el7.x86_64", ARCH:" AMD64 ", family: "Unix"Copy the code

4. Install Jenkins

4.1 yum install

sudo wget -O /etc/yum.repos.d/jenkins.repo \
    https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum upgrade
sudo yum install jenkins
sudo systemctl daemon-reload
Copy the code

4.2 war file

You can download it from www.jenkins.io/download/

To upload a WAR to the server, run:

nohup java -jar jenkins.war >/dev/null &
Copy the code

The admin account will be created for the first time. The password is:

/root/.jenkins/secrets/initialAdminPassword
Copy the code

Get the password by cat:

[root@localhost jenkins]# cat  /root/.jenkins/secrets/initialAdminPassword
fca057398c8f4b618794f0c2a77dbf91
Copy the code

Five, access,

The default port is 8080. If you cannot access http://ip:8080, check whether the port is open and enter the obtained password.

Select the initialization plug-in and install the recommended:

During the process, some plug-ins may fail to be installed, so you can continue to install them manually.

To create a user, use the admin account:

Save directly to complete:

Six, plug-in installation

Before using it, we need to install some plugins that will be used:

Plugins to install: Maven Integration is used to create projects and initialize them as Maven projects

SSH Is used for SSH remote login

Publish Over SSH Is used to log in remotely Over SSH and send files

Git Parameter is used to get Git branches as parameters in a build

7. Global configuration

7.1 configure the System

7.1.1 SSH

Configuring SSH for the remote service:

The IP address, port number, and Credentials need to be specified. Currently, certificates do not exist. Add them to manage Credentials in System Configuration, as shown in the following figure:

Enter your account, password and description in the following figure:

After saving, you can select this credential in SSH configuration:

7.1.2 the Publish over SSH

As shown in the following figure, click Add to configure multiple servers

Set Remote Directory to the root Directory of subsequent file uploads

Click Advance, select Use Password, and enter the server password

Click Test Configration. If Success is displayed, the connection is successful.

7.2 Global Tool Configuration

7.2.1 JDK

Click add JDK

Deselect and enter JAVA_HOME

7.2.2 Maven

We all know that maven Settings need to be configured to use Maven. Jenkins can directly select the local file and put the file on Jenkins’ server, as shown in the picture below:

You can also use the Plugin to manage Settings on Jenkins: install Config File Provider Plugin

After the installation is complete, there are as follows:

Create a new configuration:

Fill in the Settings:

You can perform the following configuration:

Maven’s MAVEN_HOME configuration is similar to the JDK configuration, as shown below:


Guys, when you see this, give it a thumbs up!!