preface

Front-end bosses are now talking about low code, zero code, to work, but our daily work is given priority to with business requirements, but if we can make their work more repetitive things became more automated, it can have the effect of lift effect, have more time to equip themselves to learn more knowledge of skills, let his career to the next level.

The working process

This is the general workflow, most companies are more detailed

What is the Jenkins

Jenkins is an open source CI&CD software for automating a variety of tasks, including building, testing and deploying software. It is a Continuous integration tool based on Java development, used to monitor continuous repetitive work, designed to provide an open and easy to use software platform, so that software projects can be continuous integration, support a variety of operating modes. This can be through system packages, Docker, or a standalone Java program.

What is a CI

Automated testing and validation of changes that need to be incorporated to ensure that they conform to specifications, do not cause disruption to the production environment, and detect problems in the personal development portion early.

What is a CD

Automatically release production-ready builds to class production environments for early testing; Automatically release your application to production and test back as soon as possible.

Why use CI&CD

When we work more and more busy, personal time less and less of the time, always find themselves have been doing some repetitive work, and a lot of things can be through some code automation to help when we finished, you can use this time to CI&CD automation integration, can let we reduced the amount of work, improve work efficiency, Get more personal time;

With that said, let’s take a look at how Jenkins’ continuous integration works. I installed it in Mac Book:

1. Install docker first & run it

Official Download address

2. Create a local mount address

Create a local directory to mount the docker file
# name (custom name)
mkdir /Users/name/docker/jenkins
Copy the code

3.Jenkins mirror installation

The first way

# Pull mirror separately
docker pull jenkins/jenkins
# or
docker pull jenkinsci/blueocean
Copy the code

The second method is to pull the Jenkins image and mount the local host file address

docker run -u 0 -d -p 8080:8080 -p 50000:50000 --name jenkins --privileged=true -v /Users/name/docker/jenkins:/var/jenkins_home jenkinsci/blueocean
Copy the code

4. Run and unlock Jenkins

Enter the URL address in the browser window to access http://localhost:8080. There will be a long waiting process. After launching, you will see a page to unlock Jenkins

You can obtain the password in the following ways:

  1. Run commands on the terminal to view information

cat /var/lib/jenkins/secrets/initialAdminPassword2. Direct access to the host machine to mount a local file, which is my Mac folder/Users/name/docker/Jenkins, in this address, initialAdminPassword find files, using a text editor to open 3. Open the Logs log of Jenkins service through the Docker client interface, and you can see the password in it

5. Install the plug-in

Jenkins will have a plugin that he recommends. Just install it. It’s a bit slow, depending on the speed

6. Create an administrator

7. Configure the Jenkins URL

If you have a public IP address or a domain name you’ve configured, you can just replace localhost if you don’t have a local IP address, you can download an Intranet penetration tool, I use this NATAPP > this is in order to access gitlab | gitee | making while waiting for the code hosting service use, and Internet access

8. Create a new task to test

Create a free-style task

Select shell script execution, random input a little content to save

Build immediately

At this point, we can see that our project construction is complete, no problem, this time you can plug in Gitee to try it out

Install the Gitee & Jersey 2 API plug-in

Return to the home page, select System Management, enter plug-in management and download directly

When you’re done, you can reboot it, Jenkins

Configuring Jenkins Environment

After the installation is complete, go back to the home page and select System Administration and System Configuration

Configure the Jenkins URL, which can be modified here if it was not configured at the beginning

Notice That the Intranet address is unavailable, causing gitee to fail to access the Intranet. You can use the public IP address or Intranet penetration tool to solve the problem. You can use the public IP address or Intranet penetration tool to solve NATAPP

Get Jenkins user API Token, click Add Token, and generate it directly. Store the Token by yourself, otherwise you need to regenerate it later

Enter the project we just created and start configuring the project

After configuration directly

Configure gitee information

Gitee webhooks generated

Add a WebHooks

URL format http://(jenkins username) :(Jenkins user API token) @(Jenkins URL)/ gizee-project /project

Set up the Gitee personal access token

Generate a token directly. This token, like the Jenkins API token, needs to be saved separately as it is only displayed once

The test code

Tests directly in Webhooks

Submit your own repository code tests

git push origin master
Copy the code

This is the Jenkins + Gitee self-built CI process, you can try it yourself, besides Gitee, it can also be other, such as Gitlab, Github, etc., as long as the corresponding webhooks are configured, you can execute the corresponding code in the desired phase, such as: push, merge, etc

Thank you for your attention. This article is mainly my experience of making CI tools during this period of time, in case I forget it for a long time, so I make a record and hope it can help other students.