Jenkins and other tools with GitHub achieve continuous integration testing

Jenkins integrated configuration GitHub

Jenkins download and install

Jenkins Windows version can be downloaded from the official website (jenkins-ci.org) in, Jenkins GitHub integration requires a higher version, it is recommended to select the latest stable version.
Open the installation package follow the prompts to complete the installation.
Jenkins Web-based service, as a service starts, the default access port is 8080. After successful installation, enter the installation directory Jenkins in cmd, and then enter the following command to start the service:
Here Insert Picture Description
If you want to turn Jenkins, simply enter in the URL field http: // localhost: After 8080 / exit, click OK, you can
Close Jenkins:
Here Insert Picture Description
address in local access is http: // localhost: 8080 /. When the client remote access, replace localhost for the server IP address can be, that http://192.104.103.101:8080/. After the start, Jenkins entered the main interface, some versions need to enter the main interface by entering the administrator account
as shown in the main interface:
Here Insert Picture Description
Then install the GitHub related plug-ins
Here Insert Picture Description
in order to allow Jenkins can connect to their GitHub account
the need to establish a new token to go to GitHub and grant permission gist, ropo, user
Here Insert Picture Description
and then the new credentials in Jenkins Lane, pay attention to set the type for the Secret text, and then enter the token at the Secret
Here Insert Picture Description
establish credentials success
Here Insert Picture Description
also need to specify GitHub Server will just put the established credentials in Jenkins settings, API to connect to the GitHub
Here Insert Picture Description
In order to achieve the Jenkins project on GitHub pull and automatically updated, and automatic deployment, will check on the hock when configuring GitHub Server, configure both good hock on GitHub project
to create a new Repository, and configure the hock
Here Insert Picture Description
Jenkins in New Task, select the type Freestyle project
Here Insert Picture Description
selection GitHub project, the project's .git fill url
Here Insert Picture Description
source management is set to git, while input url and configuration items .git, and set a good GitHub account login certificate, the certificate can establish new GitHub account credentials implementation, and finally designated branch
Here Insert Picture Description
to build a trigger, check the Web hock, GitHub of hock function enabled, configure polling, monitor real-time changes in the code to update
Here Insert Picture Description
the new task is completed
Here Insert Picture Description
after the New task wait a bit to see the project built automatically, GitHub project and existing files to pull up
Here Insert Picture Description
the following tests to verify whether the GitHub project is successfully configured, Jenkins can automatically update in the workspace by hock to achieve
a new text.txt file locally, and push the project to GitHub repository, you can see the GitHub repository has been shown text.txt file
Here Insert Picture Description
Jen kins in the ongoing construction of
Here Insert Picture Description
building is completed, so far can be considered Jenkins + GitHub integrated environment configuration

Continuous integration with Maven as a build tool

向GitHub远程仓库上传maven项目
在Jenkins中安装maven相关插件
Here Insert Picture Description
在Jenkins中配置好jdk及maven版本,不然无法添加maven任务

Here Insert Picture Description
创建maven任务
Here Insert Picture Description
选择GitHub项目,将项目.git的url填入
Here Insert Picture Description
源码管理设置为git,同时输入项目.git的url与配置,并且设置好GitHub账号登录的证书,证书可以通过新建立GitHub账号凭据实现,最后指定分支
Here Insert Picture Description
构建触发器,勾选Web Hock,启用GitHub的hock功能,同时配置轮询,监听代码变动实现实时更新
Here Insert Picture Description
配置maven
Here Insert Picture Description
新建任务完毕
稍等一会,就可以看到Jenkins自动从GitHub仓库拉取maven项目,项目构建完毕
Here Insert Picture Description
可以在控制台输出看到下载了maven相关依赖
Here Insert Picture Description

基于Blue Ocean的 Pipeline

Jenkins中通过安装Blue Ocean插件,可以快速创建 Pipeline, Pipeline将原本独立运行于单个或者多个节点的任务连接起来,实现单个任务难以完成的复杂流程,形成流水式发布,构建步骤视图化
如图所示,创建GitHub项目的流水线
Here Insert Picture Description
可创建流水式集成测试方案,会按照流水线进行一步步测试
Here Insert Picture Description
在保存后Jenkins会自动在GitHub远程仓库里创建 Jenkinsfile然后将刚刚所设置的测试步骤转化为代码,然后Jenkins会开始执行测试
Here Insert Picture Description
通过 Pipeline可以很方便实现流水式的持续交付,执行阶段通过视图一目了然

邮件系统集成

Open SMTP service in the mailbox, and then configure SMTP server settings Jenkins
various different SMTP mail service code, service code corresponding to the need to consult
Here Insert Picture Description
the configuration shown in FIG success
Here Insert Picture Description
of Extended E-mail Notification configuration
Here Insert Picture Description
after opening provided in the build task operation
Here Insert Picture Description
in which the message content (Default content) can refer to the following to fill in:

(本邮件是程序自动下发的,请勿回复!)
项目名称:$PROJECT_NAME
构建编号:$BUILD_NUMBER
svn 版本号:${SVN_REVISION}
构建状态:$BUILD_STATUS
触发原因:${CAUSE}
项目地址:${Jenkins_URL}job/${PROJECT_NAME}
文件签入记录:${Jenkins_URL}job/${PROJECT_NAME}/changes
本次构建地址:${Jenkins_URL}job/${PROJECT_NAME}/${BUILD_NUMBER}
构建日志:${Jenkins_URL}job/${PROJECT_NAME}/${BUILD_NUMBER}/console

The project changes, push to the remote repository GitHub test, Jenkins will automatically pull the latest results and constructed
Here Insert Picture Description
to receive mail
Here Insert Picture Description

Published 10 original articles · won praise 0 · Views 4425

Guess you like

Origin blog.csdn.net/Akanemiku/article/details/104270571