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:
If you want to turn Jenkins, simply enter in the URL field http: // localhost: After 8080 / exit, click OK, you can
Close Jenkins:
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:
Then install the GitHub related plug-ins
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
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
establish credentials success
also need to specify GitHub Server will just put the established credentials in Jenkins settings, API to connect to the GitHub
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
Jenkins in New Task, select the type Freestyle project
selection GitHub project, the project's .git fill url
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
to build a trigger, check the Web hock, GitHub of hock function enabled, configure polling, monitor real-time changes in the code to update
the new task is completed
after the New task wait a bit to see the project built automatically, GitHub project and existing files to pull up
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
Jen kins in the ongoing construction of
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相关插件
在Jenkins中配置好jdk及maven版本,不然无法添加maven任务
创建maven任务
选择GitHub项目,将项目.git的url填入
源码管理设置为git,同时输入项目.git的url与配置,并且设置好GitHub账号登录的证书,证书可以通过新建立GitHub账号凭据实现,最后指定分支
构建触发器,勾选Web Hock,启用GitHub的hock功能,同时配置轮询,监听代码变动实现实时更新
配置maven
新建任务完毕
稍等一会,就可以看到Jenkins自动从GitHub仓库拉取maven项目,项目构建完毕
可以在控制台输出看到下载了maven相关依赖
基于Blue Ocean的 Pipeline
Jenkins中通过安装Blue Ocean插件,可以快速创建 Pipeline, Pipeline将原本独立运行于单个或者多个节点的任务连接起来,实现单个任务难以完成的复杂流程,形成流水式发布,构建步骤视图化
如图所示,创建GitHub项目的流水线
可创建流水式集成测试方案,会按照流水线进行一步步测试
在保存后Jenkins会自动在GitHub远程仓库里创建 Jenkinsfile然后将刚刚所设置的测试步骤转化为代码,然后Jenkins会开始执行测试
通过 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
the configuration shown in FIG success
of Extended E-mail Notification configuration
after opening provided in the build task operation
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
to receive mail