Я хочу развернуть мое приложение с maven на удаленном сервере, чтобы иметь непрерывную систему интеграции :).maven-tomcat plugin deploy on Remote server
Я проверил множество проблем в stackoverflow, но не смог заставить его работать. Сначала я покажу вам свою ошибку, а затем конфигурацию, которую я сделал. Здесь си сообщения о загрузке, то кажется правильным: Uploaded: http://SERVEUR_IP/manager/text/deploy?path=%2FGiveMeAShow (49631 KB at 51.5 KB/sec)
Ошибка:
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project GiveMeAShow: Tomcat return http status error: 401, Reason Phrase: Unauthorized:
[ERROR] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
[ERROR] <html>
[ERROR] <head>
[ERROR] <title>401 Unauthorized</title>
[ERROR] <style type="text/css">
[ERROR] <!--
[ERROR] BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}
[ERROR] H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
[ERROR] PRE, TT {border: 1px dotted #525D76}
[ERROR] A {color : black;}A.name {color : black;}
[ERROR] -->
[ERROR] </style>
[ERROR] </head>
[ERROR] <body>
[ERROR] <h1>401 Unauthorized</h1>
[ERROR] <p>
[ERROR] You are not authorized to view this page. If you have not changed
[ERROR] any configuration files, please examine the file
[ERROR] <tt>conf/tomcat-users.xml</tt> in your installation. That
[ERROR] file must contain the credentials to let you use this webapp.
[ERROR] </p>
[ERROR] <p>
[ERROR] For example, to add the <tt>manager-gui</tt> role to a user named
[ERROR] <tt>tomcat</tt> with a password of <tt>s3cret</tt>, add the following to the
[ERROR] config file listed above.
[ERROR] </p>
[ERROR] <pre>
[ERROR] <role rolename="manager-gui"/>
[ERROR] <user username="tomcat" password="s3cret" roles="manager-gui"/>
[ERROR] </pre>
[ERROR] <p>
[ERROR] Note that for Tomcat 7 onwards, the roles required to use the manager
[ERROR] application were changed from the single <tt>manager</tt> role to the
[ERROR] following four roles. You will need to assign the role(s) required for
[ERROR] the functionality you wish to access.
[ERROR] </p>
[ERROR] <ul>
[ERROR] <li><tt>manager-gui</tt> - allows access to the HTML GUI and the status
[ERROR] pages</li>
[ERROR] <li><tt>manager-script</tt> - allows access to the text interface and the
[ERROR] status pages</li>
[ERROR] <li><tt>manager-jmx</tt> - allows access to the JMX proxy and the status
[ERROR] pages</li>
[ERROR] <li><tt>manager-status</tt> - allows access to the status pages only</li>
[ERROR] </ul>
[ERROR] <p>
[ERROR] The HTML interface is protected against CSRF but the text and JMX interfaces
[ERROR] are not. To maintain the CSRF protection:
[ERROR] </p>
[ERROR] <ul>
[ERROR] <li>Users with the <tt>manager-gui</tt> role should not be granted either
[ERROR] the <tt>manager-script</tt> or <tt>manager-jmx</tt> roles.</li>
[ERROR] <li>If the text or jmx interfaces are accessed through a browser (e.g. for
[ERROR] testing since these interfaces are intended for tools not humans) then
[ERROR] the browser must be closed afterwards to terminate the session.</li>
[ERROR] </ul>
[ERROR] <p>
[ERROR] For more information - please see the
[ERROR] <a href="/docs/manager-howto.html">Manager App HOW-TO</a>.
[ERROR] </p>
[ERROR] </body>
[ERROR]
[ERROR] </html>
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Это кажется довольно ясно, что это проблема авторизации. Давайте посмотрим на мой удаленный файл tomcat7-users.xml кот:
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<role rolename="manager-script"/>
<role rolename="admin-script"/>
<user username="admin" password="password" roles="manager-gui,manager-script,admin-gui,admin-script" />
</tomcat-users>
Я знаю, что я не должен предоставить все роли, но эй, это не работает, так что я пытаюсь :).
Я могу войти на страницу администратора приложения/администратора через HTTP в своем браузере с помощью «admin» и «password». Думаю, все в порядке.
Вот моя конфигурация в Maven-TOMCAT-плагин:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<usernamee>admin</usernamee>
<password>password</password>
<url>http:SERVEUR_IP/manager/text</url>
<server>TomcatServer</server>
<path>/GiveMeAShow</path>
</configuration>
</plugin>
Когда я начал пробовать я не смог загрузить файл войны. Добавление этого позволило мне сделать это. Но, похоже, проблема авторизации приходит позже.
Я также поместить файл settings.xml в моем удаленном сервере в ~/.m2/settings.xml
:
<?xml version='1.0' encoding='utf-8'?>
<servers>
<server>
<id>TomcatServer</id>
<username>admin</username>
<password>password</password>
</server>
</servers>
Папка ~/.m2
содержит только одну вложенную и этот файл, который я создал.
Обратите внимание, что я делаю все это с использованием пользователя root.
Я не знаю, что попробовать сейчас, спасибо за вашу помощь!
EDIT
Я сделал, как @fatteddy сказал: - Создано развертывание только для пользователей. Только с ролью «менеджер-скрипт» - Исправлена ошибка в моей pom.xml, изменение <usernamee>
к </username>
Я думаю, что пользователь привыкли это развертывание только сделал большую часть работы, как я тестировал на TRAVIS-CI в то же время с переменными env в <username>
тегах, написанных без ошибок.
Привет, просто не забудьте: я создаю только пользователя, ориентированного на развертывание, с ролью «только менеджер-сценарий». Затем, если он не работает, я пытаюсь изменить целевой URL-адрес модуля плагина tomcat-maven. Я не понимаю разницы между «менеджером/текстом» и «менеджером/текстом», который вы цитировали: /. Конечно, мне нужно перезагрузить tomcat: :). Благодарим за помощь – ogdabou
Да, чтобы развернуть конкретного пользователя - и извините -> забыл добавить недостающую конечную косую черту (исправил ее). – fateddy
Хорошо, спасибо, работая над этим :) – ogdabou