You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Jenkins上传WAR文件至Tomcat,无法找到manager账号密码求助

Troubleshooting Tomcat Manager Credentials for Jenkins WAR Deployment

Hey there! Let's work through why you can't locate or use the Tomcat Manager's username and password to deploy your WAR file via Jenkins. Here are the critical configurations and steps you might have overlooked:

1. Verify Tomcat's User Configuration File

First, check the core user setup file for Tomcat: TOMCAT_HOME/conf/tomcat-users.xml. This is where you define users with access to the Manager app.

You need to add a user with both manager-gui (for web interface access) and manager-script (for API-based deployments like Jenkins) roles. Add this snippet inside the <tomcat-users> tag:

<user username="jenkins-deployer" password="your-strong-password" roles="manager-gui,manager-script"/>

Note: Replace jenkins-deployer and your-strong-password with your preferred credentials.

2. Adjust Manager App Access Restrictions

By default, Tomcat restricts Manager access to local IPs. If Jenkins is running on a different server (or even the same machine but via a non-local endpoint), you need to update the context config:

Go to TOMCAT_HOME/webapps/manager/META-INF/context.xml and modify the RemoteAddrValve section. For example:

  • If Jenkins is on the same server, you can keep the default but ensure your Jenkins process is accessing via localhost.
  • If Jenkins is on another server, add its IP to the allow list:
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
       allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|192.168.1.100"/>

Replace 192.168.1.100 with your Jenkins server's actual IP. You can also temporarily comment out this Valve to test if access restrictions are the issue.

3. Restart Tomcat After Configuration Changes

Any edits to Tomcat's config files won't take effect until you restart the server. Run these commands (adjust for your OS):

  • Linux/macOS:
    $ TOMCAT_HOME/bin/shutdown.sh
    $ TOMCAT_HOME/bin/startup.sh
    
  • Windows:
    TOMCAT_HOME\bin\shutdown.bat
    TOMCAT_HOME\bin\startup.bat
    

4. Validate Jenkins Credential Setup

Once Tomcat is configured correctly, double-check your Jenkins deployment configuration:

  • Ensure you've created a Username with password credential in Jenkins using the exact username and password you defined in tomcat-users.xml.
  • In your Jenkins job's deployment step (e.g., "Deploy war/ear to a container"), select this credential and confirm the Tomcat Manager URL is correct (usually http://<tomcat-server>:<port>/manager/text for script-based access).
  • Test the connection directly from Jenkins to rule out typos or credential mismatches.

Common Pitfalls to Watch For

  • Missing Manager App: If the manager folder doesn't exist in TOMCAT_HOME/webapps, you might have installed Tomcat without the Manager application. Reinstall Tomcat with the full distribution or deploy the Manager WAR manually.
  • Firewall/Security Group Blocks: Ensure the Tomcat server's port (default 8080) is open to incoming traffic from Jenkins.
  • Credential Typos: Even a single wrong character in the username or password will cause authentication failures—triple-check these values.

内容的提问来源于stack exchange,提问作者Srinivasa Tadipatri

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:34:26