About --Jenkins automated deployment, installation and simple to use

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,
Here Insert Picture Description

2, install jenkins


3, edit /etc/sysconfig/jenkinsmodify the startup user rootHere Insert Picture Description

4, open the jenkins
Here Insert Picture Description
Here Insert Picture Description
5, before starting to view this directory is empty after the start will generate the appropriate file
Here Insert Picture Description

6、登录web页面进行安装:http://172.25.2.7:8080
Here Insert Picture Description
7、根据界面的提示信息去服务端查看密码并输入

 cat /var/lib/jenkins/secrets/initialAdminPassword 

Here Insert Picture Description

Here Insert Picture Description

8、上个步骤执行成功后,会弹出下面的对话框

Here Insert Picture Description
9、安装插件,完成后,就安装成功了。

Here Insert Picture Description

  • 在这里安装插件时,可以加速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

Here Insert Picture Description
Here Insert Picture Description此时,点击系统管理,点击管理插件,查看Jenkins已安装的插件

Here Insert Picture Description至此Jenkins部署就完成了。

2.2 Jenkins的简单使用

1、创建第一个简单的工程
Here Insert Picture Description
至此Jenkins部署就完成了。
2、输入项目名称(first job)并选择构建一个自由风格的软件项目

Here Insert Picture Description
3、上面创建完成后跳转进来后进行配置,选择丢弃旧的构建(下面保持天数一般在5~7天即可)

Here Insert Picture Description
4、接着选择构建,然后选择Execute Shell 来执行shell命令
Here Insert Picture Description
5、既然可执行shell命令,执行一个pwd,看下默认的工作目录在哪里

Here Insert Picture Description

6、上面保存后点击立即构建,就会在下面生成一个build history蓝色即表示正常,若红色即表示有问题,构建完成后,我们可以点击build ID下拉框选择控制台输出来查看详细信息

Here Insert Picture Description

7、点击控制台输出,通过输出信息我们可以看到Jenkins默认的工作目录在 /var/lib/jenkins/workspace/(项目名称)

Here Insert Picture Description
8、那么我们创建一个文件,返回工作台,点击配置

Here Insert Picture Description

9、创建一个test.txt文件并保存

Here Insert Picture Description10、点击立即构建,同样查看构建后的控制台输出,可以看到构建成功

Here Insert Picture Description
11、我们进入服务器的项目目录,进行验证是否创建成功

Here Insert Picture Description

Published 102 original articles · won praise 21 · views 5314

Guess you like

Origin blog.csdn.net/ranrancc_/article/details/103510613