您好,登錄后才能下訂單哦!
本篇內容介紹了“通過jenkins發布java項目到目標主機上的步驟是什么”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
拉取代碼并打包
mvn clean package
備份目標服務器上已有的要發布項目
將包傳到目標服務器的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發布java項目到目標主機上的步驟是什么”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。