Linux implementation jenkins + svn + maven + tomcat under full deployment

 Ali cloud (Centos7.3) server used

1, the deployment of the Java environment (jdk and tomcat I follow online tutorials Ann, is very simple, remember to configure the environment variable on the line)

Deployment jdk:

  

Jdk check whether the successful deployment

  

2. Download the latest package and deploy tomcat tomcat

 

In your browser to http: // IP: 8080, the following description appears tomcat deployment success

Second, the installation jenkins

Download Jenkins package, currently under me for Jenkins ( (2.124)) version:

The jenkins package in tomcat under the webapps directory and restart tomcat:

 

Access in the browser HTTP: // IP: 8080 / Jenkins (according to their own tomcat to fill in port) to obtain the following figure:

We find the file in the above red path on the server and extract the password to enter the next step

Enter the password and click Next to enter the following interface, we can select the default plug-in installation can skip automatically install the plugin, go in Ann row , and this was off-line, there will be plug-in behind the selection is empty (novice personal advice to skip the plug-in, so when you can deploy all know which plugins are installed)

Click it to skip the plug-in installed into the interface

 

So we will Jenkins installation is complete

Three, Jenkins global configuration tools

点击系统管理-->全局工具配置-->jdk和maven的配置-->点击保存(个人建议jdk、maven之类的全局工具都自己安装,这样你还能多学一遍安装流程)

在服务器上部署maven

由此maven部署完毕

四、建立第一个项目,回到首页-->创建一个新任务-->如下图,发现没有maven项目

这时就需要安装maven插件如下图(我们项目就是maven的 所以我上来就需要安装maven)

先安装svn以下的插件,后回到项目配置

安装完插件不需要重启jenkins,页面显示安装完成即可,接下来我们就开始初步配置项目

构建项目备注配置svn库,这个根据需求填写svn库,此处也可以填写其他的,比如svn

配置pom.xml文件,这必不可少(1、maven项目 Root Pom 要写你的相对路径,如果你Svn地址没有指到pom.xml目录的话,你的Root Pom需要将路径补充完整指向pom.xml。2、Goals and options 填写maven打包命令 各个公司不一样,你们自行填写)

目前项目基本上已部署完毕,接下来立即构建

 

到此为jenkins+maven+svn的发布全过程,以下的为在发布上扩展到远程发布

六、ssh配置

安装Publish Over SSH和SSH插件(我理解的就是从jenkins服务器把war/jar包传输到项目服务器上,哈哈)

点击jenkins界面上的系统管理-系统设置 ,点击下方的Publish over SSH

填写SSH Servers

Name:随便起,尽量填写自己能看懂这是哪个服务器的名字

Hostname:项目服务器ip

Username:root

Remote Dicectory:/

之后点击高级中的Use password authentication, or use a different key后下方填写项目服务器密码,填写完成后点击最后的Test configuration 测试下是否可以连通(有测试出现问题的,可以私信我,帮你们解决)。

 填写完成,记得保存和应用

进入项目的配置页面构建环境,在构建后操作选择

下图为ssh各个信息填写例子和介绍

Source files: target/cadsa-0.0.1.jar(填写target中jar包相对路径)

Remove prefix:target/(将前缀去掉,指的是只要一个jar不需要带前面目录)
Remote directory:/root/tomcat/webapps/(此处填写发送到项目服务器的哪个路径下,填写绝对路径)

Exec command:这个里面可以填写一些远程命令,包括重启tomcat 执行你的脚本等等,有想要脚本的可以评论,私信我

点击保存,ssh配置完毕

这是我近期成功的例子,所以发出来,有些东西也是网上找的,有些自己添加的,希望对大家有帮助

 

Guess you like

Origin www.cnblogs.com/ShaoJie666/p/11208608.html