运行Jenkins部署任务
一、运行Jenkins部署任务1. 执行Jenkins部署任务2. 打开浏览器访问部署应用程序3. 确定发布结果的正确性4. 确认执行结果成功1. 执行Jenkins部署任务查看控制台输出异常信息如下:Started by user adminRunning as SYSTEMBuilding remotely on TestEnv in workspace /...
·
一、运行Jenkins部署任务
- 1. 执行Jenkins部署任务
- 2. 打开浏览器访问部署应用程序
- 3. 确定发布结果的正确性
- 4. 确认执行结果成功
- 1. 执行Jenkins部署任务
- 查看控制台输出
异常信息如下:
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/order
at 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 TestEnv
at 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/order
at 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 directory
at 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 directory
at 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
异常解决方案:
请跳转:https://blog.csdn.net/weixin_40816738/article/details/90280863
- 2. 打开浏览器访问部署应用程序
- 浏览器访问:http://192.168.45.145:8090/
现在成功部署成功了!!!!
- 浏览器访问:http://192.168.45.145:8090/
- 3. 确定发布结果的正确性
- 4. 确认执行结果成功
本章回顾
本章讲述了
- 典型的自动化部署任务过程
- 并实际创建了一个Jenkins自动化部署任务开发中的一些要素
- 实际执行自动化部署任务
通过这个任务,我们可以看到测试环境被自动化的创建了出来。有了这个任务我么尝试一下,实战环节。
在实战中我们实际体验一下如何达到开发修改代码,推送远程github仓库,测试一键部署测试环境
- 附上:deploy.sh脚本内容:
#!/usr/bin/env bash
#编译+部署order站点
#需要配置如下参数
# 项目路径, 在Execute Shell中配置项目路径, pwd 就可以获得该项目路径
# export PROJ_PATH=这个jenkins任务在部署机器上的路径
# 输入你的环境上tomcat的全路径
# export TOMCAT_APP_PATH=tomcat在部署机器上的路径
### base 函数
killTomcat()
{
pid=`ps -ef|grep tomcat|grep java|awk '{print $2}'`
echo "tomcat Id list :$pid"
if [ "$pid" = "" ]
then
echo "no tomcat pid alive"
else
kill -9 $pid
fi
}
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
# 复制新的工程
cp $PROJ_PATH/order/target/order.war $TOMCAT_APP_PATH/webapps/
cd $TOMCAT_APP_PATH/webapps/
mv order.war ROOT.war
# 启动Tomcat
cd $TOMCAT_APP_PATH/
sh bin/startup.sh
更多推荐
已为社区贡献10条内容
所有评论(0)