当前位置:网站首页>[cloud native • Devops] master the continuous integration tool Jenkins
[cloud native • Devops] master the continuous integration tool Jenkins
2022-07-21 12:25:00 【Developer pony】
Catalog
One 、 Continuous integration tools Jenkins Introduce
1. What is continuous integration
Two 、Jenkins Installation and deployment
3、 ... and 、Jenkins Global configuration
1. Git Installation and configuration
2. JDK Installation and configuration
3. maven Installation and configuration
3、 ... and 、 Upload the code to Git The server
1. Gogs The construction and configuration of
2. Upload local code to Gogs The warehouse of
Four 、 Task creation and execution
One 、 Continuous integration tools Jenkins Introduce
1. What is continuous integration
Continuous integration (Continuous Integration,CI). With the increasing complexity of software development , How to better coordinate development to ensure the quality of software development has become the goal of the development team , Especially in recent years “ agile development ” The rise of the Internet , How to quickly adapt to the changing needs and ensure the development quality is particularly important .
Continuous integration is a kind of software development practice aiming at such problems , Advocacy teams must often integrate their work , And every integration is verified through automated construction , Include automatic compilation 、 Release 、 test , So as to find integration errors faster , Let the team develop cohesive software faster .
Continuous integration has the following characteristics :
- It is an automated periodic integration testing process , Check out code from 、 Compiling and constructing 、 Run the test , And then to the result record 、 Test statistics are automatically completed , No manual intervention required
- A dedicated integration server is needed to perform integration builds
- Need to be supported by code hosting tools
The emergence of continuous integration , Ensure the quality of the code delivered by the development team , Reduce the pressure of software release ; The second is to complete the whole process automatically , It doesn't need much human intervention , It greatly reduces the repeated process , Save time 、 Workload and cost .
2. Jenkins Introduce
Jenkins Original name Hudson,2011 The year is amended as Jenkins, It's a Open source tools for continuous software integration . The official website is as follows: ( There are also Chinese websites ):
Jenkins It can monitor the errors in the integration in real time , Provide detailed log files and reminders , The trend and stability of project construction can also be vividly displayed in the form of charts .
Jenkins It has the following characteristics :
- Easy to install : Download the official website and run it directly
- Easy to configure : Provides friendly GUI Configuration interface
- Change support : It can get and generate code update list from code warehouse , Output to compile output information
- Support permanent links : The user is through Web To visit Jenkins Of , And these Web The link address of the interface is permanent , It can be used directly in any document
- Integrate E-mail/RSS/IM
- JUnit/Test NG Test report : Provide test reports in the form of charts
- File fingerprint information : Which integration builds will be saved and what results jars file , Which integration uses which version jars Documents and other records
- Support for third-party plug-ins
Two 、Jenkins Installation and deployment
1. install Jenkins
First step , download Jenkins Installation package , open Jenkins Official documents ;
Click on “Installing Jenkins”, You can see the various versions available for download ;
choice Linux( The demo virtual machine is CentOS System ) Under the CentOS System ;
You can see the official online installation method ;
open Xhell And connect the virtual machine / The server , Follow these steps to download ;
# Download mirroring
wget -O /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo
# install
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
# to update
yum upgrade
# install Java Environmental Science
yum install java-11-openjdk
# install Jenkins
yum install jenkins
2. Local access Jenkins
Jenkins After installation , You can use virtual machine / The server IP: port Visited locally , The initial interface is as follows ;
According to the prompt, the password is saved in /var/lib/jenkins/secrets/initialAdminPassword Directory ;
Enter the password and enter the following interface ;
We choose to install the recommended plug-ins ,Jenkins It will start to download and install automatically , The following is being installed ;
After installation , Create our first user ;
Get into Jenkins The home page is as follows ;
3. Plug in installation
Using the recommended installation method can only help us install some of the most commonly used plug-ins , There are some plug-ins such as maven We still need to install it manually .
Click on “ System management ” --> “ Plug-in management ”;
Here we can see the plug-ins we need , Download on demand ;
4. uninstall Jenkins
# rpm uninstall Jenkins
rpm -e jenkins
# Check if the uninstall is successful
rpm -ql jenkins
# Completely delete the remaining files
find / -iname jenkins | xargs -n 1000 rm -rf
3、 ... and 、Jenkins Global configuration
The purpose of global configuration is tell Jenkins Where are the paths of various tools , bring Jenkins These software can be called through plug-ins . We all download the compressed package and upload it to the virtual machine / The way of server .
Click on “ System management ” --> “ Global configuration ”, You can see the plug-ins that need to be configured , Configuration is required jdk、git、maven Tools ;
1. Git Installation and configuration
( Use it directly yum Although the command installation is simpler, the version will be very low , In order to prevent errors in the future, it is recommended to install in this way )
First download git Compress the package and upload it to the virtual machine / The server ;
Follow the steps below ;
#1. Decompress the package
tar -zxvf git-2.27.0.tar.gz
#2. stay Linux The system needs to compile the source code , First download the required dependencies
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
#3. Uninstall the old version of git( Installation dependency is automatically installed git, So you need to uninstall the old version )
yum -y remove git
#4. Enter the unzipped folder
cd git-2.27.0
#5. compile git Source code
make prefix=/usr/local/git all
#6. install git to /usr/local/git route
make prefix=/usr/local/git install
#7. Configure environment variables
vi /etc/profile
Add this line of code at the bottom :export PATH=$PATH:/usr/local/git/bin
#8. Refresh environment variables after configuration
source /etc/profile
After the operation is completed, use the command git --version see git edition , as follows 2.27 Version installed successfully ;
[[email protected] git-2.27.0]# git --version
git version 2.27.0
Now let's take a look at git route which git;
[[email protected] git-2.27.0]# which git
/usr/local/git/bin/git
Use this path to set the global configuration ;
2. JDK Installation and configuration
Download a jdk Of rpm Package and upload to virtual machine / The server ;
Then use the command rpm -ivh jdk-8u171-linux-x64.rpm Installation ;
The root directory after installation is /usr/java/jdk1.8.0_171-amd64;
Use this path to set the global ;
3. maven Installation and configuration
download apache-maven .tar.gz Package and upload to virtual machine / The server ;
Unzip the compressed file ;
Use this path and the extracted file name to set the global ;
After all the configuration is complete , Click save 、 Click application .
3、 ... and 、 Upload the code to Git The server
1. Gogs The construction and configuration of
Gogs It is an easy to build self-service Git service , Its goal is to create the simplest 、 Build in a fast and easy way Git service . Use Go Language development, it can be distributed through independent binary , Support Go All platforms supported by the language , Include Linux、Mac OS、Windows as well as arm platform . With the traditional Git Compared with it, its biggest advantage is that it has a graphical interface .
First step : Download mirroring docker pull gogs/gogs;
[[email protected] ~]# docker pull gogs/gogs
Using default tag: latest
latest: Pulling from gogs/gogs
97518928ae5f: Pull complete
d20a5437c0b4: Pull complete
ec9934e62f5f: Pull complete
2a880a4f6876: Pull complete
7bb13647629b: Pull complete
641b202f48eb: Pull complete
8f12f9a5cd7d: Pull complete
Digest: sha256:fbae7c126411d3fa3f8fdca17a65b196887ab23e3b7375f682a13daf5806bb19
Status: Downloaded newer image for gogs/gogs:latest
docker.io/gogs/gogs:latest
[[email protected] ~]#
The second step : establish Gogs Containers docker run -di --name=gogs -p 10022:22 -p 3000:3000 -v /var/gogsdata:/data gogs/gogs;
# Container name gogs
# Port mapping ,22 Port map to 10022,3000 Port map to 3000
[[email protected] ~]# docker run -di --name=gogs -p 10022:22 -p 3000:3000 -v /var/gogsdata:/data gogs/gogs
3af9726ff2d9430be43f7f3d78c206b9a53d356347e8a92c23316a7d2e6533f8
[[email protected] ~]#
The third step : Access in your local browser , The initial interface is as follows ;
The database type selected here is SQLite3
Change the domain name to 192.168.200.129
Modify application URL by http://192.168.200.129:3000/
Then click “ Install now ”,Gogs Installation and configuration complete ;
2. Upload local code to Gogs The warehouse of
First, we create a warehouse ;
Once created successfully, you can upload the code to the warehouse ;
Here I use idea( Local git The environment has been set up , No more details here ) And a sample project to demonstrate the upload operation ;
Selected items , Right click on the “file” --> “git” --> “Repository” --> “Reomtes”;
Next, add the remote address , That's us Gogs Address of the remote warehouse ;
At this point, you can upload the code , First click “Git” --> “Add”, Upload the project to the staging area ;
choice “git” --> “Repository” --> “push” Push ;
Enter your user name and password to log in Gogs After that, it can be pushed successfully ;
Now check again Gogs Warehouse in , You can see that the project has been uploaded to Gogs Warehouse ;
Upload the code to Git The demonstration was successful .
Four 、 Task creation and execution
Log in Jenkins, Click on “ newly build Item”, Enter the task name and select “ Construct a maven project ”;
Click on “ determine ”, Then we make the following configuration ;
Project description
Source code management
build
Configuration complete , Click save , The project is created ;
Return to panel , Click the button to perform this task ;
This operation is equivalent to getting the execution process of the project file Jenkins In the system .
边栏推荐
- Is CSDN like this now? No one reviews it?
- Introduction to database system -- analysis questions
- node 读取出某一个文件夹内的所有文件路径(此处会遍历所有文件夹,如有其他操作看着加就行了)
- 学习记录十六
- redis中使用lua脚本
- H5在线CAD后台读写CAD文件
- 支持向量机学习笔记(2)参数比较与人脸识别项目
- [thymeleaf] basic objects: base objects
- C语言程序的编译(预处理) —— 下
- Combine pyqt5 to develop one click conversion software for office documents, and there is no need to open members to transfer files in the future
猜你喜欢
[problem solving] how to transfer files to win server
c语言初学者对puts()的问题
How Jenkins sends email, advanced test hands-on to teach you
【问题解决】 怎么传输文件到win服务器
Modification and use of j-vxe-table and j-popup components in jeecg
龙蜥社区发布首个 Anolis OS 安全指南 为用户业务系统保驾护航
学习记录十六
信息化概论
Dragon Dragon community released the first Anolis OS Security Guide to escort users' business systems
NeRF数据集介绍
随机推荐
Week 5 - Neural Networks and Neural Language Models
1. Mx6u system migration-4-uboot migration
[ruoyi] database copy data
Reasons and solutions for more data entries than the original data table after left join/inner join
redis中使用lua脚本
支持向量机学习笔记(1)
结合pyqt5开发办公文档一键转换软件,以后再也不用开会员转文件了
C语言程序的编译(预处理) —— 下
ES6中 async 函数、await表达式 的基本用法
Leetcode breaks the 8W mark
C语言之NULL的含义
Face Huawei? Apple and Qualcomm quickly reconciled, but the price behind it is very high!
【MySQL】 insert into ... select ...
Introduction to informatization
不就是个TCC分布式事务,有那么难吗?
分享丨写在工作13年后,个人的一点软件测试经历及感想……
WPS前骨干历时10年打造新型软件,Excel用户:我为此改用WPS
什么是组合(Composition),有什么作用
Mysql:Error Code 1235,This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME
H5在线CAD后台读写CAD文件