發(fā)布java項(xiàng)目的步驟:
- 拉取代碼并打包
- mvn clean package
- 備份目標(biāo)服務(wù)器上已有的要發(fā)布項(xiàng)目
- 將包傳到目標(biāo)服務(wù)器的webapss目錄中
- 需做免密登錄
- 重啟目標(biāo)服務(wù)器的tomcat服務(wù)
- 修改項(xiàng)目的配置
- 重啟目標(biāo)服務(wù)器的tomcat服務(wù)
項(xiàng)目要求:
兩臺(tái)主機(jī)上分別安裝jenkins,tomcat
jenkins主機(jī)上操作
#兩臺(tái)主機(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
新建項(xiàng)目
拉取代碼鏈接:https://gitee.com/neawalke/tomcat-java-demo.git
當(dāng)拉取的代碼是私有倉(cāng)庫(kù)
測(cè)試訪問頁面
到此這篇關(guān)于通過jenkins發(fā)布java項(xiàng)目到目標(biāo)主機(jī)上的文章就介紹到這了,更多相關(guān)jenkins發(fā)布java項(xiàng)目?jī)?nèi)容請(qǐng)搜索服務(wù)器之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持服務(wù)器之家!
原文鏈接:https://blog.csdn.net/NeaWalke/article/details/120844558