Simple use of Jenkins, Xiaobai tutorial

1. What is CI/CD

The core concepts of CI/CD can be summarized in three points:

  • continuous integration
  • continuous delivery
  • continuous deployment

Code launch process: pull code -> build -> test -> package -> deploy

1.1 CI(Continuous Integration)

"CI" in CI/CD always refers to continuous integration

1.2 CD(Continuous Delivery/Continuous Deployment)

The "CD" in CI/CD refers to Continuous Delivery and/or Continuous Deployment

Jenkins is an open source CI/CD software, which can be regarded as the leader of CI/CD software. It provides more than 1,000 plug-ins to support construction, deployment, and automation, which can basically meet the needs of any project.

The Jenkins workflow is shown in the figure:

 Start building the Jenkins environment

1. First, prepare a private warehouse and upload the test code, for example: create a new warehouse on gitee, and you can see the effect of the test code itself.

2. We need a server to run Jenkins, and a server to store our project code. Friends who don’t have extra servers at hand know that they can be deployed separately during real development. There is no requirement here. After our code is submitted to Gitee in the future, Gitee will notify Jenkins of this event through a POST request, thereby triggering the build operation of Jenkins . So this requires Gitee to be able to access your Jenkins server, so if your Jenkins happens to be built on the server, this is easy, but if it is built locally, you have to penetrate through the intranet such as peanut shells Tools come to assist your work, which is more troublesome, and the speed of the Internet will also be limited.

3. First connect to the server

 In order to facilitate management, use docker to install

Install docker first, see How to install Docker on CentOS7 for details

4. Next, start and create the Jenkins container

# Create jenkins directory
mkdir /data/jenkins_home/
# Modify the owner of the directory so that the Jenkins container can operate the directory
chown -R 1000:1000 /data/jenkins_home/
 

docker run -d --name jenkins -p 8088:8080 -p 50000:50000 -v /data/jenkins_home:/var/jenkins_home jenkins/jenkins

The renderings are as follows:

http://localhost:8088 Execute the above command, after the installation is successful, you can access it  by typing in the browser  . (The local virtual machine accesses the above address, and the server is changed to its own ip address)

Note: If there is no error when starting, but the port is empty when you use docker ps -a to view it, it may be because your virtual machine does not have jdk installed, just download and install it.

jdk8 download address

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

jdk11 download address

http://openjdk.java.net/projects/jdk/11/

 The browser opens the interface as follows:

 Passwords can be passed:

cat /var/jenkins_home/secrets/initialAdminPassword

This command checks, where jenkins_home is, write it there,

It may also be as under data:

cat /data/jenkins_home/secrets/initialAdminPassword

After entering the password, enter this page, the novice can directly select and install the recommended plug-in for the first time

 The installation may fail due to network reasons, just try again

 Choose any login, here I directly choose admin to log in

 

 Click all the way to the Jenkins operation page. However, please note that many of the plug-ins we installed just now will not take effect until restarted, so we enter docker restart jenkins to restart jenkins.

The password is obtained with the cat command above, and you can log in.

The plug-ins required to deploy different projects are different. Take the Spring boot project as an example. Next, we install three necessary plug-ins:

  • Maven Integration: Maven build tool
  • Publish Over SSH: The entire tool will upload the jar packaged by Jenkins to the application server in the future.
  • Gitee: Assistance with using the Gitee repository.

After the installation is successful, restart Jenkins.

Configure Jenkins

After all this is done, we start configuring Jenkins

....

Guess you like

Origin blog.csdn.net/a2285786446/article/details/127645326