1.背景及现象

在配置Jenkins的自动部署功能,手动构建时报“The username you provided is not allowed to use the text-based Tomcat Manager (error 403)”错误,如图:

.jpg)

2.原因

用于tomcat7自动部署的管理用户必须具有manager-script角色,manager-gui角色是不够的,不然会有错误出现:
The username you provided is not allowed to use the text-based Tomcat Manager (error 403)
在/etc/tomcat7/tomcat-users.xml文件中为管理用户添加manager-script角色即可。

3.解决方法

  1. 进入到tomcat的conf目录下,编辑tomcat-users.xml配置文件

    1
    2
    3
    4
    <role rolename="admin-gui"/>
    <role rolename="manager-gui"/>
    <role rolename="manager-script"/>
    <user username="tomcat" password="tomcat" roles="admin-gui,manager-gui,manager-script"/>
  2. 进入到tomcat的webapps/manager/META_INF/context.xml文件,将文件中对访问的来源受限设置注释

1
2
3
4
5
6
7
8
<Context antiResourceLocking="false" privileged="true" >
<!--注释掉此代码-->
<!--
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
  1. 重启tomcat,再次构建即可

原文链接 https://www.cnblogs.com/wanghy898/p/11257574.html

原文链接 https://blog.csdn.net/Jay_1989/article/details/52861620?utm_source=blogxgwz2