jenkins 整合maven,svn(配置鈎子程序實現提交代碼自動構建),tomcat實現熱部署(windows+linux分別實現)


springboot : https://blog.csdn.net/zjh_746140129/article/details/80904876

1 准備工作:

(1)運行jenkins的tomcat

(2)運行我們項目的tomcat

(3)SVN服務器

jenkins就是一個war包,相信大家都非常熟悉,扔在tomcat  webapp下就能跑,具體操作步驟上網去搜一搜一大把,我們主要是來記錄一下如何實現鈎子程序,實現代碼的動態部署。

jenkins配置的話我們需要配置jdk,maven,maven的settings.xml,服務器的tomcat。

jenkins第一次進入后台會提示去下載插件,我們只要耐心等待一會兒就好,因為我們要實現熱部署,所以需要另外手動去下載一個叫depoly to container 的插件, 直接ctrl+f全局搜索就行。

 

 

其余配置如下:過程太簡單直接略過

 

 

 

maven 項目打包方法

 

 

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<tomcat-users>
<!--
  NOTE:  By default, no user is included in the "manager-gui" role required
  to operate the "/manager/html" web application.  If you wish to use this app,
  you must define such a user - the username and password are arbitrary. It is
  strongly recommended that you do NOT use one of the users in the commented out
  section below since they are intended for use with the examples web
  application.
-->
<!--
  NOTE:  The sample user and role entries below are intended for use with the
  examples web application. They are wrapped in a comment and thus are ignored
  when reading this file. If you wish to configure these users for use with the
  examples web application, do not forget to remove the <!.. ..> that surrounds
  them. You will also need to set the passwords to something appropriate.
-->
<!--
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
  <user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
  <user username="role1" password="<must-be-changed>" roles="role1"/>
-->
<role rolename="manager-gui"/>

<role rolename="manager-script"/>

<role rolename="manager-jmx"/>

<role rolename="manager-status"/>

<user username="tomcat_user" password="123456" roles="manager-gui,manager-script,manager-jmx,manager-status" />

</tomcat-users>

 

 

這樣我們的項目就自動部署到服務器的tomcat上面了,接下來就該如何自動觸發鈎子程序,去實現自動構建了。

我們進入svn服務器根目錄:

@echo off
start cmd /c "curl -X post -v -u admin:你的jenkins登錄密碼 http://127.0.0.1:8080/jenkins/view/all/job/mavent/build?token=TOUCH_TOKEN"

windows 上想要使用curl命令需要下載curl插件,然后配置環境變量后才能起作用。

最后我們修改svn的登錄權限

 

那么現在只要在本地電腦提交代碼到svn服務器,即會自動觸發構建了!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3.2  自動化部署

 

自動化的具體體現:向版本庫提交新的代碼后,應用服務器上自動部署,用戶或測試人員使用的馬上就是最新的應用程序。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4

 

更多 Java –大數據前端 –python 人工智能資料下載,可訪問百度:尚硅谷官網


JavaEE 高級課程系列

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

搭建上述持續集成環境可以把整個構建、部署過程自動化,很大程度上減輕工作量。對於程序員的日常開發來說不會造成任何額外負擔——自己把代碼提交上去之后,服務器上運行的馬上就是最新版本——一切都發生在無形中。

 

下面我們講帶領大家一步一步搭建整套持續集成環境,這個操作過程只需要細心認真即可,沒有任何難度。但是需要優秀的你具備以下前置知識:

 

ü  Linux 基本操作命令和 VIM 編輯器使用

 

ü  Maven 的項目構建管理

 

ü  GitHub SVN 使用

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM