Jenkins使用Tomcat服务器登录问题"登录信息无效。请再试一次"

时间:2017-10-28 17:40:33

标签: tomcat jenkins

我在Windows机器(OS-Windows 10)中设置了Jenkins。我完成了设置并运行Jenkins并在浏览器中通过点击http://localhost:8080进行测试(默认端口为8080)。因此,Jenkins的独立实例可以正常使用端口号8080.但是当我尝试使用Tomcat服务器时,我无法登录。虽然它启动了Jenkins登录页面。以下是我到目前为止的尝试 -

1)我安装了Jenkins并在浏览器中使用http://localhost:8080进行了测试。它运行正常。我可以使用默认的管理员凭据登录。

2)我通过运行命令jenkins.exe stop来关闭Jenkins服务。由于Tomcat服务器也在同一端口上运行。

enter image description here

3)我安装了Tomcat并点击了网址http://localhost:8080。我可以看到服务器的主屏幕。

4)我从目录jenkins.war复制了C:\Program Files (x86)\Jenkins文件,并部署在webapp服务器的Tomcat文件夹中。它说Jenkins正在运行。

enter image description here

5)现在在浏览器中,当我点击网址http://localhost:8080/jenkins时,我可以看到Jenkins的登录屏幕。我输入了仅由Jenkins提供的相同凭据(文件Username:admin中的默认凭据 - Password:fcb77f29d0e34cabab385b74709e5f3cinitialAdminPassword)。

enter image description here

现在我的查询来了。我可以在两种情况下看到Jenkins登录屏幕(Jenkins Standalone实例和Jenkins与Tomcat)。我在两种情况下都输入了上述凭据,但默认凭据仅适用于Jenkins Standalone而不适用于Tomcat。

enter image description here

我错过了什么或者我不知道什么?

1 个答案:

答案 0 :(得分:0)

我自己解决了。看看这个。

当我使用Tomcat服务器运行Jenkins时,我尝试使用Jenkins独立的相同凭据。这就是原因,每次我尝试安装时,身份验证都会失败。那我怎么解决了? Jenkins本身使用Tomcat提供用户配置详细信息,以使Jenkins更安全。检查我们需要在tomcat-users.xml文件中添加的以下配置。

enter image description here

所以我的tomcat-users.xml文件看起来像这样 -

<?xml version='1.0' encoding='utf-8'?>
  <user username="tomcat" password="tomcat" roles="manager-gui,admin-gui"/>
  <role rolename="admin"/>
  <user username="jenkins-admin" password="secret" roles="admin"/>
</tomcat-users>