Article Directory
A, Jenkins related presentations
1.1 What is Continuous Integration?
Continuous integration (CI) refers frequently integrated into the trunk code. Continuous integration purpose is to let the products can be quickly updated, while maintaining high quality. Each integration automated build (including the compilation, publishing, automated testing) to verify that all through, so find integration errors as quickly as possible. Many teams find that this process can significantly reduce integration issues, so that the team can develop software faster.
- There are two related concepts:Continuous Delivery (CD):In the continuous delivery of continuous integration on the basis of the code is deployed to integrate closer to real operating environment class production environment. Delivered to the quality of the team or the user, for review. If the review by the code to enter the production stage. ;Continuous deployment:The next step continuous delivery, by referring to the code after the review, automated deployment to production. Continuous deployment is the highest stage of continuous delivery
1.2 What is Jenkins?
Jenkins is an open source software project, designed to provide an open and easy to use software platform that enables continuous integration software becomes possible.
Jenkins is just a platform, really works are the plug-ins. Jenkins is a continuous integration platform, the role of automated build, you can easily help us do a lot of work, such as performing some regular tasks, automatic packaging deployment, generate test reports, etc., and Jenkins has a lot of features are using plug-in is complete, so a lot of common features have been implemented, and we only need a few simple configuration to complete many complex functions.
1.3 Jenkins related functions
Mainly used for continuous monitoring duplication of work, including: 1, continuous software release / test project. 2, external monitor to call the work performed.
Second, install and simple to use Jenkins
2.1 Installation Jenkins
1, JDK installation operating environment,
2, install jenkins
3, edit /etc/sysconfig/jenkins
modify the startup user root
4, open the jenkins
5, before starting to view this directory is empty after the start will generate the appropriate file
6、登录web页面进行安装:http://172.25.2.7:8080
7、根据界面的提示信息去服务端查看密码并输入
cat /var/lib/jenkins/secrets/initialAdminPassword
8、上个步骤执行成功后,会弹出下面的对话框
9、安装插件,完成后,就安装成功了。
- 在这里安装插件时,可以加速Jenkins安装插件的速度,减少失败率
cd /var/lib/jenkins/updates/
vim default.json
替换:
:1,$s/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g
:1,$s/http:\/\/www.google.com/https:\/\/www.baidu.com/g
此时,点击系统管理,点击管理插件,查看Jenkins已安装的插件
至此Jenkins部署就完成了。
2.2 Jenkins的简单使用
1、创建第一个简单的工程
至此Jenkins部署就完成了。
2、输入项目名称(first job)并选择构建一个自由风格的软件项目
3、上面创建完成后跳转进来后进行配置,选择丢弃旧的构建(下面保持天数一般在5~7天即可)
4、接着选择构建,然后选择Execute Shell
来执行shell命令
5、既然可执行shell命令,执行一个pwd,看下默认的工作目录在哪里
6、上面保存后点击立即构建,就会在下面生成一个build history
,蓝色即表示正常,若红色即表示有问题,构建完成后,我们可以点击build ID下拉框选择控制台输出
来查看详细信息
7、点击控制台输出
,通过输出信息我们可以看到Jenkins默认的工作目录在 /var/lib/jenkins/workspace/(项目名称)
8、那么我们创建一个文件,返回工作台,点击配置
9、创建一个test.txt文件并保存
10、点击立即构建,同样查看构建后的控制台输出,可以看到构建成功
11、我们进入服务器的项目目录,进行验证是否创建成功