生活随笔
收集整理的這篇文章主要介紹了
运行Jenkins部署任务
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
一、運(yùn)行Jenkins部署任務(wù)
- 1. 執(zhí)行Jenkins部署任務(wù)
- 2. 打開瀏覽器訪問(wèn)部署應(yīng)用程序
- 3. 確定發(fā)布結(jié)果的正確性
- 4. 確認(rèn)執(zhí)行結(jié)果成功
- 1. 執(zhí)行Jenkins部署任務(wù)
- 查看控制臺(tái)輸出
異常信息如下:
Started by user admin
Running as SYSTEM
Building remotely on TestEnv in workspace /root/.jenkins/workspace/DeployOrder
No credentials specified
Cloning the remote Git repository
Cloning repository git@github.com:gb-heima/order.git> git.exe init /root/.jenkins/workspace/DeployOrder/order # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Could not init /root/.jenkins/workspace/DeployOrder/orderat org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:813)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:605)at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:153)at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:146)at hudson.remoting.UserRequest.perform(UserRequest.java:212)at hudson.remoting.UserRequest.perform(UserRequest.java:54)at hudson.remoting.Request$2.run(Request.java:369)at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)at java.util.concurrent.FutureTask.run(FutureTask.java:266)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)at java.lang.Thread.run(Thread.java:745)Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to TestEnvat hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1743)at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357)at hudson.remoting.Channel.call(Channel.java:957)at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:146)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:132)at com.sun.proxy.$Proxy85.execute(Unknown Source)at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1152)at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1192)at hudson.scm.SCM.checkout(SCM.java:504)at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)at hudson.model.Run.execute(Run.java:1818)at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)at hudson.model.ResourceController.execute(ResourceController.java:97)at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Error performing command: git.exe init /root/.jenkins/workspace/DeployOrder/orderat org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2049)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2010)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2006)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1638)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:811)... 11 more
Caused by: java.io.IOException: Cannot run program "git.exe" (in directory "/root/.jenkins/workspace/DeployOrder/order"): error=2, No such file or directoryat java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)at hudson.Proc$LocalProc.<init>(Proc.java:249)at hudson.Proc$LocalProc.<init>(Proc.java:218)at hudson.Launcher$LocalLauncher.launch(Launcher.java:937)at hudson.Launcher$ProcStarter.start(Launcher.java:455)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2038)... 15 more
Caused by: java.io.IOException: error=2, No such file or directoryat java.lang.UNIXProcess.forkAndExec(Native Method)at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)at java.lang.ProcessImpl.start(ProcessImpl.java:134)at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)... 20 more
ERROR: Error cloning remote repo 'origin'
Finished: FAILURE
異常解決方案:
請(qǐng)?zhí)D(zhuǎn):https://blog.csdn.net/weixin_40816738/article/details/90280863
- 2. 打開瀏覽器訪問(wèn)部署應(yīng)用程序
- 瀏覽器訪問(wèn):http://192.168.45.145:8090/
現(xiàn)在成功部署成功了!!!!
- 3. 確定發(fā)布結(jié)果的正確性
- 4. 確認(rèn)執(zhí)行結(jié)果成功
本章回顧
本章講述了
- 典型的自動(dòng)化部署任務(wù)過(guò)程
- 并實(shí)際創(chuàng)建了一個(gè)Jenkins自動(dòng)化部署任務(wù)開發(fā)中的一些要素
- 實(shí)際執(zhí)行自動(dòng)化部署任務(wù)
通過(guò)這個(gè)任務(wù),我們可以看到測(cè)試環(huán)境被自動(dòng)化的創(chuàng)建了出來(lái)。有了這個(gè)任務(wù)我么嘗試一下,實(shí)戰(zhàn)環(huán)節(jié)。
在實(shí)戰(zhàn)中我們實(shí)際體驗(yàn)一下如何達(dá)到開發(fā)修改代碼,推送遠(yuǎn)程github倉(cāng)庫(kù),測(cè)試一鍵部署測(cè)試環(huán)境
- 附上:deploy.sh腳本內(nèi)容:
#!/usr/bin/env bash
#編譯+部署order站點(diǎn)#需要配置如下參數(shù)
# 項(xiàng)目路徑, 在Execute Shell中配置項(xiàng)目路徑, pwd 就可以獲得該項(xiàng)目路徑
# export PROJ_PATH=這個(gè)jenkins任務(wù)在部署機(jī)器上的路徑# 輸入你的環(huán)境上tomcat的全路徑
# export TOMCAT_APP_PATH=tomcat在部署機(jī)器上的路徑### base 函數(shù)
killTomcat()
{pid=`ps -ef|grep tomcat|grep java|awk '{print $2}'`echo "tomcat Id list :$pid"if [ "$pid" = "" ]thenecho "no tomcat pid alive"elsekill -9 $pidfi
}
cd $PROJ_PATH/order
mvn clean install# 停tomcat
killTomcat# 刪除原有工程
rm -rf $TOMCAT_APP_PATH/webapps/ROOT
rm -f $TOMCAT_APP_PATH/webapps/ROOT.war
rm -f $TOMCAT_APP_PATH/webapps/order.war# 復(fù)制新的工程
cp $PROJ_PATH/order/target/order.war $TOMCAT_APP_PATH/webapps/cd $TOMCAT_APP_PATH/webapps/
mv order.war ROOT.war# 啟動(dòng)Tomcat
cd $TOMCAT_APP_PATH/
sh bin/startup.sh
總結(jié)
以上是生活随笔為你收集整理的运行Jenkins部署任务的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。