我正在尝试使用 shell 命令将 WAR 从 Jenkins 部署到 tomcat6.0.39 服务器,但它无法部署并抛出授权错误:
401 Unauthorized
You are not authorized to view this page. If you have not changed any configuration files, please examine the file conf/tomcat-users.xml in your installation. That file must contain the credentials to let you use this webapp.
以下是我的 shell 命令:
curl -T $WORKSPACE/target/myapp-1.0-RC1.war 'http://serverIP:8080/manager/deploy?update=true&path=/myapp'-u username:password
但是上面的命令在我的 tomcat 6.0.24 上运行良好。我确实根据 tomcat 文档将 tomcat 用户角色定义为 manager-gui 和 manager-script 以及 manager-jmx,即从 Tomcat 6.0.30 开始,使用管理器应用程序所需的角色已从单个管理器角色更改为 以下四个角色。
- 管理器-gui
- 管理脚本
- 经理-jmx
- 经理身份
以下是我的tomcat-users.xml内容:
<tomcat-users>
<user username="managergui" password="tomcatManager" roles="manager-gui"/>
<user username="manager" password="tomcatManager" roles="manager-script"/>
我在导致授权异常的 tomcat-users.xml 或我的 shell 命令中做错了什么。
最佳答案
不要用 curl 命令“复制”war。使用 Jenkins 部署应用程序 Deploy plugin它将简化您的流程。
关于shell - Jenkins war 部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29829960/