我有一个名为'SampleMavenDeploy1'的jenkins作业,它将上游项目('SampleMavenBuild1')中的工件(war文件,pom.xml)成功复制到此项目。
我有这个项目的以下配置:
“
构建步骤:
Copy artifacts from another project
Project Name:SampleMavenBuild1
构建后操作:
War/Ear files:MavenWebAppV14/target/*.war
Context Path:webapps
Containers:
Tomcat7.x
Manager username:tomcat
Manager Password:tomcat
Tomcat Url:http://localhost:8080/manager/text
“
SampleMavenBuild1的构建(制作maven项目的war文件)已成功。在此作业的工作空间(SampleMavenDeploy1)中,存在war文件(MavenWebAppV14 / target / MavenWebAppV14.war)。我还配置了tomcat-users.xml来添加用户名'tomcat',密码'tomcat'和角色'manager-gui'和'manager-script'的用户。
我在jenkins构建的工作中面临以下错误。此作业旨在通过CI服务器在tomcat7上部署war文件。我还在jenkins中安装了“部署到tomcat”插件。
由用户vikas
启动Building in workspace C:\Users\vikachou\.jenkins\jobs\SampleMavenDeploy1\workspace
Copied 2 artifacts from "SampleMavenBuild1" build number 4
Deploying C:\Users\vikachou\.jenkins\jobs\SampleMavenDeploy1\workspace\MavenWebAppV14\target\MavenWebAppV14.war to container Tomcat 7.x Remote
ERROR: Publisher hudson.plugins.deploy.DeployPublisher aborted due to exception
org.codehaus.cargo.container.ContainerException: Failed to redeploy [C:\Users\vikachou\.jenkins\jobs\SampleMavenDeploy1\workspace\MavenWebAppV14\target\MavenWebAppV14.war]
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:189)
at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:116)
at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:103)
at hudson.FilePath.act(FilePath.java:918)
at hudson.FilePath.act(FilePath.java:896)
at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683)
at hudson.model.Run.execute(Run.java:1770)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Unknown command /manager/text/list
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:566)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:686)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:699)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:174)
... 16 more
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Unknown command /manager/text/list
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:566)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:686)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:699)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:174)
at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:116)
at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:103)
at hudson.FilePath.act(FilePath.java:918)
at hudson.FilePath.act(FilePath.java:896)
at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683)
at hudson.model.Run.execute(Run.java:1770)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Finished: FAILURE
任何能够找到答案的人都会受到欢迎。 在此先感谢!!!
答案 0 :(得分:3)
您需要授予文本管理器部署权限。
只需转到tomcat-users.xml并添加:
<user username="tomcat" password="password" roles="manager-script"/>
或者只是向现有的tomcat-manager用户授予manager-script
权限
答案 1 :(得分:3)
您需要在部署URL中将基本URL设置为localhost:8080 /,而不是管理员URL,即localhost:8080 / manager / text(这是我的情况)。
答案 2 :(得分:0)
我和你有同样的问题。但是我让tomcat用户刷新了这个问题的第一个答案,问题仍然存在于Jenkins身上。
当我尝试使用我的导航器连接到tomcat管理区域时,tomcat没有向我显示该页面,因为未安装tomcat-admin软件包。所以我已经安装了tomcat7-admin
包并重新启动了tomcat:
sudo apt-get install tomcat7-admin
sudo service tomcat7 restart
然后问题得到解决。这是因为詹金斯无法与该计划联系。太容易了!
答案 3 :(得分:0)
您要做的就是添加用户并分配manager-gui(用于GUI访问)和manager-script(用于Jenkins部署之类的访问)。另外,请确保编辑文件/webapps/manager/META-INF/context.xml,以注释掉Valve或为allow属性定义适当的正则表达式
答案 4 :(得分:-1)
如果在tomcat上部署jenkins.war文件时显示连接错误或无法加载,请按照以下步骤操作。
将jenkins文件夹粘贴到tomcat / webapps中。
重启tomcat(localhost或ip:8080 / jenkins)
Jenkins将加载并可能要求输入密码。
要获取jenkins管理员密码,请运行
{cat /opt/tomcat/.jenkins/secrets/initialAdminPassword}
如果拒绝该权限以访问密码
sudo chmod 0777 /opt/tomcat/.jenkins/secrets/initialAdminPassword
或者在那里运行ls -a
,你会看到.jenkins文件夹。