通過jenkins發(fā)布java項目到目標主機上的詳細步驟
更新時間:2021年10月22日 09:12:05 作者:NeaWalke
這篇文章主要介紹了通過jenkins發(fā)布java項目到目標主機上的詳細步驟,發(fā)布java項目的步驟很簡單,通過拉取代碼并打包,備份目標服務器上已有的要發(fā)布項目,具體內(nèi)容詳情跟隨小編一起看看吧
發(fā)布java項目的步驟:
- 拉取代碼并打包
- mvn clean package
- 備份目標服務器上已有的要發(fā)布項目
- 將包傳到目標服務器的webapss目錄中
- 需做免密登錄
- 重啟目標服務器的tomcat服務
- 修改項目的配置
- 重啟目標服務器的tomcat服務
項目要求:
兩臺主機上分別安裝jenkins,tomcat
jenkins主機上操作
#兩臺主機做免密登錄 [root@localhost ~]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:0zPiM+3ypvmYPisJbeL8LhA2QApiAVqwF9C+gyASonU root@localhost.localdomain The key's randomart image is: +---[RSA 3072]----+ |OB+ | |Xoo.E | |*=.. | |=.= . | |+o + . S + | |. + o o. + o | | = + .+ . | | + o oB. | | +ooBO+ | +----[SHA256]-----+ [root@localhost ~]# ssh-copy-id root@192.168.8.131 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" The authenticity of host '192.168.8.131 (192.168.8.131)' can't be established. ECDSA key fingerprint is SHA256:WbxvLgdwExwRlMT4gaAC1bVyIovZnAwwX1DX8dv6Rs0. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@192.168.8.131's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@192.168.8.131'" and check to make sure that only the key(s) you wanted were added. #安裝軟件 [root@localhost ~]# yum -y install git maven
新建項目
拉取代碼鏈接:https://gitee.com/neawalke/tomcat-java-demo.git



當拉取的代碼是私有倉庫





測試訪問頁面

到此這篇關于通過jenkins發(fā)布java項目到目標主機上的文章就介紹到這了,更多相關jenkins發(fā)布java項目內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
Spring?Boot的優(yōu)點及項目創(chuàng)建步驟詳解
這篇文章主要介紹了Spring?Boot的優(yōu)點及項目創(chuàng)建步驟,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-09-09
Java Swing 非常漂亮外觀Nimbus的使用方法實例
Java Swing 非常漂亮外觀Nimbus的使用方法實例,需要的朋友可以參考一下2013-02-02
SpringBoot3中token攔截器鏈的設計與實現(xiàn)步驟
本文介紹了spring boot后端服務開發(fā)中有關如何設計攔截器的思路,文中通過代碼示例和圖文講解的非常詳細,具有一定的參考價值,需要的朋友可以參考下2024-03-03

