通過jenkins發(fā)布java項目到目標(biāo)主機(jī)上的詳細(xì)步驟
發(fā)布java項目的步驟:
- 拉取代碼并打包
- mvn clean package
- 備份目標(biāo)服務(wù)器上已有的要發(fā)布項目
- 將包傳到目標(biāo)服務(wù)器的webapss目錄中
- 需做免密登錄
- 重啟目標(biāo)服務(wù)器的tomcat服務(wù)
- 修改項目的配置
- 重啟目標(biāo)服務(wù)器的tomcat服務(wù)
項目要求:
兩臺主機(jī)上分別安裝jenkins,tomcat
jenkins主機(jī)上操作
#兩臺主機(jī)做免密登錄 [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
當(dāng)拉取的代碼是私有倉庫
測試訪問頁面
到此這篇關(guān)于通過jenkins發(fā)布java項目到目標(biāo)主機(jī)上的文章就介紹到這了,更多相關(guān)jenkins發(fā)布java項目內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
基于hibernate實現(xiàn)的分頁技術(shù)實例分析
這篇文章主要介紹了基于hibernate實現(xiàn)的分頁技術(shù),結(jié)合實例形式分析了Hibernate分頁技術(shù)的原理,實現(xiàn)步驟與相關(guān)實現(xiàn)技巧,需要的朋友可以參考下2016-03-03Spring?Boot的優(yōu)點及項目創(chuàng)建步驟詳解
這篇文章主要介紹了Spring?Boot的優(yōu)點及項目創(chuàng)建步驟,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-09-09Java Swing 非常漂亮外觀Nimbus的使用方法實例
Java Swing 非常漂亮外觀Nimbus的使用方法實例,需要的朋友可以參考一下2013-02-02SpringBoot3中token攔截器鏈的設(shè)計與實現(xiàn)步驟
本文介紹了spring boot后端服務(wù)開發(fā)中有關(guān)如何設(shè)計攔截器的思路,文中通過代碼示例和圖文講解的非常詳細(xì),具有一定的參考價值,需要的朋友可以參考下2024-03-03