Teach you how to deploy Jenkins step by step, even beginners can learn it (Multi-picture warning)!

background

The company's front-end and back-end construction and deployment work are all done manually. As the business expands, the project iteration speed becomes faster, the number of personnel increases, and various problems are exposed. I will share the front-end and back-end automation based on Jenkins through a simple case. The process of workflow building, after building this workflow, we only need to initiate a git submission locally, and the rest of the single-package build, code deployment, email reminders and other functions are all automated, allowing continuous integration, continuous delivery, and continuous deployment It becomes simple and easy to operate, and truly solves many problems of manual construction and deployment.

What is Jenkins?

Jenkins is a popular open source continuous integration tool in the industry, widely used in project development, with functions such as automated construction, testing and deployment.

War package installation

Download the Jenkins War package from the official website and
start the command, java -jar jenkins.war --httpPort=8080
can be used -server -Xms1024m -Xmx2048m -XX:PermSize=256m -XX:MaxPermSize=512m to limit the memory occupied by Jenkins
3. The browser opens http: //127.0.0.1:8080/

4. Find the initialization password
insert image description here

5. Select default plugins

insert image description here

6. Wait for the download to complete
insert image description here

7. Set login password

Download the plugin
Manage Jenkins->Manage Plugins->Advanced (bottom)

Increase download speed to replace default Url

http://mirror.esuni.jp/jenkins/updates/update-center.json

Manage Jenkins->Manage Plugins->Optional Plugins

Install the following plugins

1. Publish Over SSH is used to connect to remote servers
2. Deploy to container plugin is used to publish packaged applications to remote servers
3. Maven Integration plugin
4. Pipeline Maven Integration Plugin
5. Gitlab Hook Plugin (automatically compiled when git is submitted)
6. GitLab Plugin (automatically compiled when git is submitted)
7. GitLab Authentication Plugin (automatically compiled when git is submitted)
8. WebHook (automatically compiled when git is submitted)

9. After the Locale download is complete, go to Locale->Set zh-CN in the global configuration
insert image description here
1. Dingding [Dingding] Plugin Dingding Jenkins Notifier
2. Multiple SCMs (configure multiple git)
3. Git Parameter Plug-In (parameterization configuration)

global configuration

Manage Jenkins->Global Tool Configuration
insert image description here

Publish over SSH (multiple servers can be configured for remote push)
insert image description here 

Create a new maven project

Click to create a new item
insert image description here

insert image description here
Remarks: If there are parent-child programs, the parent project should be installed in the warehouse first.
Or download the plug-in: Multiple SCMs (configure multiple git)
insert image description hereto force a custom maven warehouse
job–>configure–>Build–>Goals and options:
clean package -Dmaven.repo.local=D:\dev\maven3.1.1\m2repository

If you want to automate the build after submitting the code,
you need to configure: (requires permission)

insert image description here

insert image description here
After successful configuration
insert image description here 

Click test to test automatic deployment

Jenkins parameterized configuration (choose branch deployment)
1. Download the plug-in Git Parameter

2. Configuration parameter properties
insert image description here

insert image description here
3. Final effect
insert image description here 

Jenkins configuration DingTalk notification

1. Configure DingTalk robot

insert image description here

2. Install DingTalk notification plug-in
insert image description here 

insert image description here
3. Configure the notification after the project is built
insert image description here 

insert image description here
4. Configure Jenkins to send messages to DingTalk
insert image description here 

5. Final result
insert image description here 

Jenkins permission management

Install the plug-in Role-based Authorization Strategy
to access: Jenkins permission management reference

Jenkins server cross-service password-free execution of shell scripts

Scenario: In many cases, Jenkins is deployed on a separate server, and the packaged service package is sent to the target server to start. Inevitably there are customized operations:

For example: before sending to the target server, first back up the service package running on the current server, and a customized shell script is required to perform this operation. It is definitely not reliable to enter the password every time.
Therefore, it is necessary to configure the Jenkins server to log in to the target server without password.

Appendix
docker deployment is not recommended, it is recommended to use war to start Jenkins to download the image

docker pull jenkins/jenkins:lts

install mirror 

docker run --name jenkins --user=root -p 8080:8080 -p 50000:50000 -v /Users/wei/Documents/jenkins_home:/var/jenkins_home -d jenkins/jenkins:lts

 unmount container

docker rm -f $(docker ps -a |  grep "jenkins"  | awk '{print $1}')

              [The following is the most complete software test engineer learning knowledge architecture system diagram in 2023 that I compiled]


1. From entry to mastery of Python programming

2. Interface automation project actual combat

3. Actual Combat of Web Automation Project


4. Actual Combat of App Automation Project

5. Resume of first-tier manufacturers


6. Test and develop DevOps system

7. Commonly used automated testing tools


Eight, JMeter performance test

9. Summary (little surprise at the end)

life is long so add oil. Every effort will not be let down, as long as you persevere, there will be rewards in the end. Cherish your time and pursue your dreams. Don't forget the original intention, forge ahead. Your future is in your hands!

Life is short, time is precious, we cannot predict what will happen in the future, but we can grasp the present moment. Cherish every day and work hard to make yourself stronger and better. Firm belief, persistent pursuit, success will eventually belong to you!

Only by constantly challenging yourself can you constantly surpass yourself. Persist in pursuing your dreams and move forward bravely, and you will find that the process of struggle is so beautiful and worthwhile. Believe in yourself, you can do it!

Guess you like

Origin blog.csdn.net/nhb687096/article/details/132147561