九色国产,午夜在线视频,新黄色网址,九九色综合,天天做夜夜做久久做狠狠,天天躁夜夜躁狠狠躁2021a,久久不卡一区二区三区

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
Jenkins入門(二)

Jenkins入門(二)

原創(chuàng) 最愛喝酸奶 最后發(fā)布于2018-09-29 19:10:24 閱讀數(shù) 4255 收藏
發(fā)布于2018-09-29 19:10:24
分類專欄: # Linux高級
版權(quán)聲明:本文為博主原創(chuàng)文章,遵循 CC 4.0 BY-SA 版權(quán)協(xié)議,轉(zhuǎn)載請附上原文出處鏈接和本聲明。

25.3 Jenkins部署java項目

我們之前使用jenkins發(fā)布了php代碼,但這種需求在生產(chǎn)環(huán)境中可能用的并不多,用的更多的反而是部署java項目,java的項目是需要編譯和打包的。編譯和打包用maven完成,所以需要安裝maven。


創(chuàng)建私有倉庫

首先搭建一個私有倉庫,具體步驟可以參考這里:https://blog.csdn.net/miss1181248983/article/details/82598250 ,這里我使用另外一臺機器lzx2搭建gitlab服務器,IP是192.168.33.170。

  • 環(huán)境:
hostname:lzx		ip:192.168.33.150		role:jenkins服務器hostname:lzx1		ip:192.168.33.160		role:部署機器hostname:lzx2		ip:192.168.33.170		role:gitlab服務器
  • lzx2上安裝gitlab:
# vim /etc/yum.repos.d/gitlab.repo				#寫入下面內(nèi)容[gitlab-ce]name=Gitlab CE Repositorybaseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/gpgcheck=0enabled=1# yum install -y gitlab-ce# gitlab-ctl reconfigure				#自動配置gitlab,這個過程會花費一定時間
# netstat -lntpActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    tcp        0      0 127.0.0.1:9100          0.0.0.0:*               LISTEN      11845/node_exporter tcp        0      0 127.0.0.1:9229          0.0.0.0:*               LISTEN      12158/gitlab-workho tcp        0      0 127.0.0.1:9168          0.0.0.0:*               LISTEN      12203/ruby          tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      11704/unicorn maste tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      11756/nginx: master tcp        0      0 127.0.0.1:8082          0.0.0.0:*               LISTEN      11724/sidekiq 5.1.3 tcp        0      0 127.0.0.1:9236          0.0.0.0:*               LISTEN      12173/gitaly        tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      785/sshd            tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1359/master         tcp        0      0 0.0.0.0:8060            0.0.0.0:*               LISTEN      11756/nginx: master tcp        0      0 127.0.0.1:9121          0.0.0.0:*               LISTEN      11955/redis_exporte tcp        0      0 127.0.0.1:9090          0.0.0.0:*               LISTEN      12216/prometheus    tcp        0      0 127.0.0.1:9187          0.0.0.0:*               LISTEN      12247/postgres_expo tcp        0      0 127.0.0.1:9093          0.0.0.0:*               LISTEN      12232/alertmanager  tcp6       0      0 ::1:9168                :::*                    LISTEN      12203/ruby          tcp6       0      0 :::22                   :::*                    LISTEN      785/sshd            tcp6       0      0 ::1:25                  :::*                    LISTEN      1359/master         tcp6       0      0 :::9094                 :::*                    LISTEN      12232/alertmanager  tcp6       0      0 :::3306                 :::*                    LISTEN      1131/mysqld       # gitlab-ctl status				#查看gitlab服務狀態(tài)run: alertmanager: (pid 12232) 77s; run: log: (pid 12240) 77srun: gitaly: (pid 12173) 79s; run: log: (pid 12185) 79srun: gitlab-monitor: (pid 12203) 79s; run: log: (pid 12206) 78srun: gitlab-workhorse: (pid 12158) 80s; run: log: (pid 12164) 79srun: logrotate: (pid 11772) 136s; run: log: (pid 12165) 79srun: nginx: (pid 11756) 142s; run: log: (pid 12166) 79srun: node-exporter: (pid 11845) 123s; run: log: (pid 12186) 79srun: postgres-exporter: (pid 12247) 76s; run: log: (pid 12253) 76srun: postgresql: (pid 11478) 189s; run: log: (pid 12148) 80srun: prometheus: (pid 12216) 78s; run: log: (pid 12224) 77srun: redis: (pid 11403) 195s; run: log: (pid 12149) 80srun: redis-exporter: (pid 11955) 111s; run: log: (pid 12205) 78srun: sidekiq: (pid 11724) 151s; run: log: (pid 12151) 80srun: unicorn: (pid 11681) 157s; run: log: (pid 12193) 79s
gitlab-ctl start        啟動gitlab服務 gitlab-ctl stop         關(guān)閉gitlab服務gitlab-ctl restart      重啟gitlab服務

安裝完gitlab之后,直接在瀏覽器訪問gitlab,輸入服務器ip即可(訪問之前打開80端口)

提示修改密碼,修改完密碼后登錄(默認用戶名是root)

  • 創(chuàng)建項目,名字自定義:

  • lzx機器上生成公鑰,粘貼到SSH Keys:
# ls ~/.sshauthorized_keys  jenkins  jenkins.pub  known_hosts# ssh-keygen				#生成密鑰對Generating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa):				#直接按Enter鍵Enter passphrase (empty for no passphrase):				#直接按Enter鍵Enter same passphrase again:				#直接按Enter鍵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:rKMAgtQMA+Y93mIA3YLJk3zt089oouBCWNiZQTVoVQI root@lzxThe key's randomart image is:+---[RSA 2048]----+|*OE**..          ||*=%..+           || BoX. .          ||+ B oo o         ||=. + .. S        ||o+. .. + o       ||o o . =          ||.. o . .         ||.   .            |+----[SHA256]-----+# ls ~/.sshauthorized_keys  id_rsa  id_rsa.pub  jenkins  jenkins.pub  known_hosts# cat ~/.ssh/id_rsa.pub				#將公鑰粘貼到gitlab頁面的SSH Keys中ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGsHhQyJY0yLD667hpzYA/DUH2bqqQpywtRdGU9PHhyiC+UapqjwnosBjnwCopJOaQ4slnn59vO/o6QOFpP6eF0E4327avM15VkObD5fht7S5Q6zfCBcWpoPahsuYDbLqVPUyHqg8jbBB3FDaRiK9EZ1dbvl1Hdzkt6XotjdVdZp1aWQK0LuY1gzf3mouoC9jB9q0whQlLZ40QCe/VrxljGGAtThjD5xAetK/Q0LjOu2u9MyPxtXltO1OacyZxwM1Fjj/p2ce2zw3P+O0Ix8mwzAfMzg+z4Xe85qfNkAySUkP4+Qqkqa348rQ7ryVWG2DYNJbFX3rN1MoWJE6xb2JZ root@lzx

按照這里配置在lzx服務器上執(zhí)行:

全局設置

# cd /home/# lsadmin  myproject# git config --global user.name "Administrator"# git config --global user.email "admin@example.com"

克隆版本庫

# git clone git@192.168.33.170:root/test-java.gitCloning into 'test-java'...warning: You appear to have cloned an empty repository.				#提示似乎克隆了一個空版本庫,沒關(guān)系,因為本來就是空版本庫# lsadmin  myproject  test-java				#多出來test-java目錄

創(chuàng)建文件并上傳

# cd test-java/# ls# touch README.md# git add !$				#增加git add README.md# git commit -m "add README"				#提交[master (root-commit) 6311ae4] add README 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 README.md# git push -u origin master				#上傳Counting objects: 3, done.Writing objects: 100% (3/3), 216 bytes | 0 bytes/s, done.Total 3 (delta 0), reused 0 (delta 0)To git@192.168.33.170:root/test-java.git * [new branch]      master -> masterBranch master set up to track remote branch master from origin.

刷新瀏覽器界面,可以看到剛剛上傳的README.md文件

到這里,我們的私有倉庫就創(chuàng)建好了。


下載Zrlog源碼

ZrLog是使用 Java 開發(fā)的博客/CMS程序,具有簡約,易用,組件化,內(nèi)存占用低等特點,自帶 Markdown 編輯器。這里我們使用Zrlog的源碼作為java代碼以作測試。

  • lzx上下載zrlog的源碼:
# cd ..# wget https://codeload.github.com/94fzb/zrlog/zip/master				#下載zrlog源碼包# du -sh master30M	master# yum install -y unzip# unzip master# lsadmin  master  myproject  test-java  zrlog-master# ls zrlog-master/bin  common  data  doc  LICENSE  mvnw  mvnw.cmd  pom.xml  README.en-us.md  README.md  service  web
  • 移動到test-java目錄:
# mv zrlog-master/* test-java/mv: overwrite ‘test-java/README.md’? y# cd test-java/# lsbin  common  data  doc  LICENSE  mvnw  mvnw.cmd  pom.xml  README.en-us.md  README.md  service  web
  • 上傳到gitlab服務器:
# git add .				#增加# git commit -m "add zrlog"				#提交# git push				#上傳Counting objects: 553, done.Compressing objects: 100% (419/419), done.Writing objects: 100% (447/447), 1.42 MiB | 0 bytes/s, done.Total 447 (delta 51), reused 0 (delta 0)remote: Resolving deltas: 100% (51/51), done.To git@192.168.33.170:root/test-java.git   ead3e2f..bf720f58  master -> master

刷新瀏覽器界面,可以看到剛剛上傳的zrlog文件


安裝tomcat

這里再使用一臺機器lzx1安裝jdk和tomcat,這里的jdk不能使用openjdk,否則后面會報錯。具體安裝步驟參考這里:https://blog.csdn.net/miss1181248983/article/details/81080091 。

  • 安裝jdk:

下載解壓

# cd /usr/local/src/# rz# lsjdk-8u181-linux-x64.tar.gz# tar zxvf jdk-8u181-linux-x64.tar.gz# mv jdk1.8.0_181/ /usr/local/jdk1.8

設置環(huán)境變量

# vim /etc/profile				#添加下面內(nèi)容JAVA_HOME=/usr/local/jdk1.8/JAVA_BIN=/usr/local/jdk1.8/binJRE_HOME=/usr/local/jdk1.8/jrePATH=$PATH:/usr/local/jdk1.8/bin:/usr/local/jdk1.8/jre/binCLASSPATH=/usr/local/jdk1.8/jre/lib:/usr/local/jdk1.8/lib:/usr/local/jdk1.8/jre/lib/charsets.jar

使其生效并檢驗

# source /etc/profile# java -versionjava version "1.8.0_181"Java(TM) SE Runtime Environment (build 1.8.0_181-b13)Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)# which java/usr/local/jdk1.8/bin/java
  • 安裝tomcat:

下載解壓

# wget https://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.32/bin/apache-tomcat-8.5.32.tar.gz# tar zxvf apache-tomcat-8.5.34.tar.gz# mv apache-tomcat-8.5.34 /usr/local/tomcat

啟動tomcat

# /usr/local/tomcat/bin/startup.shUsing CATALINA_BASE:   /usr/local/tomcatUsing CATALINA_HOME:   /usr/local/tomcatUsing CATALINA_TMPDIR: /usr/local/tomcat/tempUsing JRE_HOME:        /usr/local/jdk1.8Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jarTomcat started.# netstat -lntp |grep javatcp6       0      0 :::8080                 :::*                    LISTEN      1181/java           tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      1181/java           tcp6       0      0 :::8009                 :::*                    LISTEN      1181/java 

設置開機啟動

# echo "/usr/local/tomcat/bin/startup.sh" >> /etc/rc.d/rc.local # chmod a+x /etc/rc.d/rc.local 

打開瀏覽器,輸入機器ip:8080端口訪問

我們點擊上圖中manager webapp,會發(fā)現(xiàn)是403告警,如下圖

編輯配置文件

# vim /usr/local/tomcat/webapps/manager/META-INF/context.xml				#更改下面內(nèi)容allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|192.168.33.*" />				#增加一個33網(wǎng)段,讓jenkins可以連接tomcat

重啟tomcat

# /usr/local/tomcat/bin/shutdown.sh				#關(guān)閉tomcatUsing CATALINA_BASE:   /usr/local/tomcatUsing CATALINA_HOME:   /usr/local/tomcatUsing CATALINA_TMPDIR: /usr/local/tomcat/tempUsing JRE_HOME:        /usr/local/jdk1.8Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar# /usr/local/tomcat/bin/startup.sh				#啟動tomcatUsing CATALINA_BASE:   /usr/local/tomcatUsing CATALINA_HOME:   /usr/local/tomcatUsing CATALINA_TMPDIR: /usr/local/tomcat/tempUsing JRE_HOME:        /usr/local/jdk1.8Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jarTomcat started.

刷新tomcat界面,出現(xiàn)一個彈窗,提示輸入用戶名和密碼

增加tomcat用戶

# vim /usr/local/tomcat/conf/tomcat-users.xml				#在</tomcat-users>這行上面增加下面內(nèi)容<role rolename="admin"/><role rolename="admin-gui"/><role rolename="admin-script"/><role rolename="manager"/><role rolename="manager-gui"/><role rolename="manager-script"/><role rolename="manager-jmx"/><role rolename="manager-status"/><user name="admin" password="lzxlzxlzx"          roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status"/>				#增加用戶admin,密碼為lzxlzxlzx,后面會用到

重啟tomcat

# /usr/local/tomcat/bin/shutdown.sh Using CATALINA_BASE:   /usr/local/tomcatUsing CATALINA_HOME:   /usr/local/tomcatUsing CATALINA_TMPDIR: /usr/local/tomcat/tempUsing JRE_HOME:        /usr/local/jdk1.8Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar# /usr/local/tomcat/bin/startup.sh Using CATALINA_BASE:   /usr/local/tomcatUsing CATALINA_HOME:   /usr/local/tomcatUsing CATALINA_TMPDIR: /usr/local/tomcat/tempUsing JRE_HOME:        /usr/local/jdk1.8Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jarTomcat started.

刷新瀏覽器界面,輸入剛增加的用戶名和密碼,進入tomcat的管理頁面

只有jenkins訪問到這個后臺管理接口才能發(fā)布war包。


安裝maven

maven用來編譯源碼并打包,下載地址:http://maven.apache.org/download.cgi 。

要把maven安裝在jenkins機器上,所以得在lzx機器上操作。

  • 下載安裝:
# cd /usr/local/# wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz# tar zxvf apache-maven-3.5.4-bin.tar.gz# /usr/local/apache-maven-3.5.4/bin/mvn --version				#查看版本Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T14:33:14-04:00)Maven home: /usr/local/apache-maven-3.5.4Java version: 1.8.0_181, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/jreDefault locale: en_US, platform encoding: UTF-8OS name: "linux", version: "3.10.0-693.el7.x86_64", arch: "amd64", family: "unix"
  • 配置jenkins:

系統(tǒng)管理全局工具配置,找到Maven配置,默認 settings 提供 選擇文件系統(tǒng)中的 settings 文件,文件路徑填寫settings文件的路徑;默認全局 settings 提供選擇文件系統(tǒng)中的全局 settings 文件,文件路徑填寫settings文件的路徑。

找到Maven,點擊新增Maven,自定義名字,取消自動安裝的勾選,路徑填寫剛剛安裝maven的路徑,應用保存即可


安裝插件

  • 先在jenkins界面安裝兩個插件:

系統(tǒng)管理管理插件,安裝兩個插件:Maven IntegrationDeploy to container。Maven Integration這個插件用來構(gòu)建maven項目,Deploy to container用來發(fā)布war包到遠程機器上。

  • 安裝完插件后,重啟jenkins:
# systemctl restart jenkins
  • 重新登錄jenkins,構(gòu)建maven項目:


配置maven項目

上面點擊確定之后,jenkins會自動調(diào)到項目的配置界面,我們需要進行一些配置。

描述這里自定義

源碼管理這里選擇Git,然后Repository URL填寫我們搭建的gitlab服務器中版本庫的地址,Credentials選擇右邊的Add,添加憑據(jù)

類型選擇SSH Username with private key,用戶名自定義,私鑰這里填寫jenkins機器上和gitlab上公鑰對應的私鑰。

查看jenkins機器和gitlab上公鑰對應的私鑰(之前克隆版本庫時,我們把jenkins機器上的公鑰傳到了gitlab服務器上)

# cat ~/.ssh/id_rsa-----BEGIN RSA PRIVATE KEY-----MIIEpgIBAAKCAQEAxrB4UMiWNMiw+uu4ac2APw1B9m6qkKcsLUXRlPTx4cogvlGqao8J6LAY58AqKSTmkOLJZ5+fbzv6OkDhaT+nhdBON9u2rzNeVZDmw+X4be0uUOs3wgXFqaD2obLmA2y6lT1Mh6oPI2wQdxQ2kYivRGdXW75dR3c5Lel6LY3VXWadWlkCtC7mNYM395qLqAvYwfatMIUJS2eNEAnv1a8ZYxhgLU4Yw+cQHrSv0NC4zrtrvTMj8bV5bTtTmnMmccDNRY4/6dnHts8Nz/jtCMfJsMwHzM4Ps+F3vOanzZAMklJD+PkKpKmt+PK0O68lVhtg2DSWxV96zdTKFiROsW9iWQIDAQABAoIBAQC1FxpR5sCgk1pbGIUYSajdzuOUDAGBnhxxlvUSYr4jIOr/C8fbH0vUvMu2TjsfDPbojwsqWx4hb/T9Ky1HlDDHkbf4yVSUEqmkK1Fosy3eYxKXxgsn18L0fDTN5BQoguz8IMajz6fEjTXkkpO5yW6VVesVP0gdXtjKs8Ybxu31FXqHXaPb+LFMkLA2MpNxQ8sVNALWSrdGyKA1bL+It589x1N7NQfNRq1iqCOfipC9VVWTMwHymx0ocIa5ZXurEKNU/FEAW7kso6l6zuzWpLE1SZZ7TqsW4UlwPWPIZjZ1neh74JlGlXnz29s76Uk1xOrGzCssigE1j6a0H8hwZ0VBAoGBAOfcg83D5mjhV/BW8teOJskSD3YeK0sVUxigPAnIAzbmPWgys03jB6NMfI1meNkx7x5sl5+P7dDBOWui2wg4TP3RAlaf1Il93Xy/NW57JxnjH4BY3Yl5vvR8U0vV0LLcqss7lGuR9OUNi2Nc30cRJB/OOO+enKJPP3QqIe34Gsg1AoGBANtf3aCgItrONAlinnBrmkxRiJWSjuXBGEg3LRLk0pyJjCfiJ/0L+jVkL/tLwBYGi7plIB17N0eOr27/CJK6P4wpPN9X2hqmDoeXgf3Vxuqy+E2f+cEXIG/ftEYwLKkeKGWeEVWm7pbslCY8cjW8/mIgbZQVyMUOTv7rwjVRA94VAoGBANBCoBkIp0L5dbWpQ8MeKfRdRooAGz77zoHGG2dlwo1jTTD0qV2CWO/y2cVgj5f3ZCLdw2tNKn1hsaPeygKeH3m0bPdF5PACoBlW3jV4ZOy5tyffqk27jyunKGJrkWO3Faoqv+vHVEMRYWxElUEOQnZXE4kX3PVlXUeIOKW5PsUpAoGBALYtyaav9eIRpkM5A+zGX1AL0cqs+ECy99BZCfSL1J+s1pj0hlLt1G7scbBWOwHPk9BKVL5G6iRhySz7XIpFY6qpQGUV1wmUZ7KQzqIXG2cjE3Oba9S/uO9PLq2vKheT9OZWu3yO8cqiU3HhdtNLzVF+LqHw6VdER7QJ47FVQ0n1AoGBAKz15tgMf6q58dnpxxY9EwVfNOFiwU9uO48JAQ3dG/kxnA7N2J5m8lkU7ErL0EFqGhD8uiL8IR3/5mQkYDPreKl4iztonVXexxdNN7HVEAMRYn0a5sGAyOLSE7HkkS45jeZEGr/JmxVWjbAhAvM4buMYcyAfhqOxIabOIbuXnwxv-----END RSA PRIVATE KEY-----

我們生成密鑰對時沒有設置密碼,所以Passphrase可以留空,下面的也留空,點擊添加即可

Credentials選擇Git,可以發(fā)現(xiàn),之前的紅色提示沒有了,說明沒問題

構(gòu)建觸發(fā)器、構(gòu)建環(huán)境、Pre Steps部分全部保持默認;Build下面Root POM為 pom.xml,Goals and options填寫clean install -D maven.test.skip=truePost Steps、構(gòu)建設置部分保持默認;

點擊增加構(gòu)建后操作步驟,選擇Deploy war/ear to a container,WAR/EAR files填寫**/*.war,表示全部的war包;Contex path留空;Containers選擇 Tomcat 8.x ,Tomcat URL填寫我們安裝tomcat服務器的地址,我的是http://192.168.33.160:8080

Credentials點擊Add,用戶名這里填admin,密碼填lzxlzxlzx,這里的用戶名密碼就是登錄tomcat后臺管理入口的賬號密碼,其它保持默認,添加即可

然后Credentials這里選擇admin/******

繼續(xù)點擊增加構(gòu)建后操作步驟,選擇Editable Email Notification,Project Recipient List這里添加自己的郵箱,用英文逗號分隔,其它位置保持默認

然后點擊Advanced Setting,定位到Triggers,可以在Add Trigger處增加發(fā)郵件的條件,這里如果是Always就可以了

最后點擊應用、保存即可。


立即構(gòu)建

上面配置完后,我們開始構(gòu)建。點擊立即構(gòu)建

然后我們在構(gòu)建歷史下面選中#1 ,下拉點擊控制臺輸出,可以看到我們剛剛構(gòu)建的輸出內(nèi)容

第一次構(gòu)建時會稍慢,因為會下載很多和maven相關(guān)的東西,查看到最后結(jié)果,這里有報錯

查看郵箱郵件

回到lzx機器上,安裝jdk:

因為之前安裝tomcat時lzx1機器上有安裝jdk,所以我這里可以直接從lzx1拷到lzx上# scp -r 192.168.33.160:/usr/local/jdk1.8 /usr/local/jdk1.8     root@192.168.33.160's password:				#輸入密碼# /usr/local/jdk1.8/bin/java -version				#查看版本java version "1.8.0_181"Java(TM) SE Runtime Environment (build 1.8.0_181-b13)Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

回到jenkins界面,回到首頁,點擊系統(tǒng)設置全局工具配置JDK,別名自定義,然后路徑填剛剛安裝jdk的路徑,然后應用、保存即可

重啟jenkins服務:

# systemctl restart jenkins

重新登錄jenkins界面,回到java-test,再次構(gòu)建,查看控制臺輸出

查看郵箱郵件

反復修改一些東西后試了幾次,發(fā)現(xiàn)還是有問題。于是我重新更換zrlog的版本做測試(最先我用的是zrlog-2.0.6版本,然后換成了zrlog-1.8.0版本)

# cd ..# wget https://github.com/redhatxl/zrlog/archive/master.zip# du -sh master.zip 1.6M	master.zip# yum install -y unzip# unzip master# ls admin  master  master.zip  myproject  test-java  zrlog-master# ls zrlog-master/bin  CHANGELOG.md  doc  LICENSE  mvnw  mvnw.cmd  pom.xml  README.md  src# mv zrlog-master/* test-java/mv: overwrite ‘test-java/README.md’? y# cd test-java/# lsbin  CHANGELOG.md  doc  LICENSE  mvnw  mvnw.cmd  pom.xml  README.md  src

上傳到gitlab服務器上

再次構(gòu)建,還是遇到和之前一樣的問題

到網(wǎng)上搜了一下報錯信息,都說是tomcat內(nèi)存溢出導致自動部署失敗,修改內(nèi)存的值之后繼續(xù)構(gòu)建,還是報一樣的錯。

我嘗試去查看tomcat服務器上的webapps目錄

# cd /usr/local/tomcat/# ls webapps/docs  examples  host-manager  manager  ROOT  zrlog-1.8.0  zrlog-1.8.0.war  zrlog-2.0.6  zrlog-2.0.6.war				#這里多出來我之前兩次實驗的zrlog的war包

刷新tomcat的后臺管理頁面

發(fā)現(xiàn)多出來zrlog1.8.0和zrlog2.0.6

lzx1上刪除這兩個war包及其解壓文件

# cd webapps/# rm -rf zrlog-*# lsdocs  examples  host-manager  manager  ROOT

再次在jenkins界面構(gòu)建,還是和之前一樣的報錯

查看webapps

zrlog1.8版本的war包又出現(xiàn)了

刷新tomcat的后臺管理頁面

只有zrlog1.8.0

至此,jenkins雖然部署到能把war包發(fā)布webapps目錄下,但是由于不知名原因,jenkins一直有報錯,而且war運行不起來,望知道原因的大佬給個回復,有時間我會在嘗試弄弄。


更多資料參考:

jenkins詳解

搭建jenkins實現(xiàn)自動化部署

本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Linux下的Jenkins+Tomcat+Maven+Git+Shell環(huán)境的搭建使用(jenkins自動化部署)
Jenkins+SVN+Maven+Shell 實現(xiàn)項目一鍵發(fā)布
jenkins安裝部署全過程
Jenkins Docker持續(xù)集成
pinpoint的安裝部署
【云原生】第十一篇
更多類似文章 >>
生活服務
熱點新聞
分享 收藏 導長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服