使用 Jenkins 将 war 文件部署到 Tomcat 的推荐方法?
Recommended way to deploy a war-file to a Tomcat using Jenkins?
我正在寻找如何自动(重新)部署 war-文件 myPortal.war
到 Tomcat 服务器上的黄金方式使用 Jenkins,假设 Tomcat 在另一台带有 Tomcat-manager 运行 的机器上是 运行。我当前 Jenkins 工作中的相关 powershell 构建步骤如下:
$user = "foo"
$pass = "bar"
$secpass = ConvertTo-SecureString $pass -AsPlainText -Force
$ServerURL = $ENV:Server
$Path = $ENV:WORKSPACE
$credential = New-Object System.Management.Automation.PSCredential($user, $secpass)
Invoke-WebRequest -URI "$($ServerURL)/manager/text/undeploy?path=/myPortal"
-Method GET -Credential $credential -UseBasicParsing
Invoke-WebRequest -InFile "$($Path)\myPortal.war"
-URI "$($ServerURL)/manager/text/deploy?path=/myPortal&update=true"
-Method PUT -Credential $credential
-ContentType 'application/zip' -UseBasicParsing
在这里,我使用了 undeploy
-命令,如 Tomcat Documentation 所述。 我的问题详解:
- 是否真的有必要将 Tomcat-manager-GUI 运行 和相应的凭据硬编码到 Jenkins-job 中?考虑到我无法通过网络安装我的服务器,难道没有比这更优雅的方法吗?
- 在什么情况下 我可以在部署 WAR 文件之前省略未部署 而没有 运行 存在之前部署遗留的风险在目录
myPortal
? 中徘徊
- 另一个问题是脚本可能会失败(例如由于错误的凭据),而 Jenkins 作业不会失败。
我是 Jenkins 的 Tomcat-plugin 的 ware,但是这个 (a) 还要求 Tomcat-manager 是 运行 和 ( b) 我无法使用 Jenkins Choice 参数 重新部署($ServerURL
和 %ServerURL
都不起作用)这似乎是 Jenkins issue不可能使用参数化容器。
以下是最相关的相关帖子,但它们没有回答我的问题:
- Cannot successfully deploy war file in tomcat using jenkins
- Re-deploying a "versioned" war file from Jenkins to Tomcat fails
- Jenkins auto deploy tomcat 7
仅作记录:我们目前使用的解决方法是让其他一些软件进行部署。这样做的原因不是上述安全问题,而是我们的客户要求使用他们选择的专有软件打包服务 XYZ。 Jenkins 现在所做的就是使用该软件打包服务的 API 上传 WAR 文件。
我很欣赏这是一个较旧的 post 但我已经在 unix 服务器上使用 Jenkins 和 curl 使其工作...
我正在寻找如何自动(重新)部署 war-文件 myPortal.war
到 Tomcat 服务器上的黄金方式使用 Jenkins,假设 Tomcat 在另一台带有 Tomcat-manager 运行 的机器上是 运行。我当前 Jenkins 工作中的相关 powershell 构建步骤如下:
$user = "foo"
$pass = "bar"
$secpass = ConvertTo-SecureString $pass -AsPlainText -Force
$ServerURL = $ENV:Server
$Path = $ENV:WORKSPACE
$credential = New-Object System.Management.Automation.PSCredential($user, $secpass)
Invoke-WebRequest -URI "$($ServerURL)/manager/text/undeploy?path=/myPortal"
-Method GET -Credential $credential -UseBasicParsing
Invoke-WebRequest -InFile "$($Path)\myPortal.war"
-URI "$($ServerURL)/manager/text/deploy?path=/myPortal&update=true"
-Method PUT -Credential $credential
-ContentType 'application/zip' -UseBasicParsing
在这里,我使用了 undeploy
-命令,如 Tomcat Documentation 所述。 我的问题详解:
- 是否真的有必要将 Tomcat-manager-GUI 运行 和相应的凭据硬编码到 Jenkins-job 中?考虑到我无法通过网络安装我的服务器,难道没有比这更优雅的方法吗?
- 在什么情况下 我可以在部署 WAR 文件之前省略未部署 而没有 运行 存在之前部署遗留的风险在目录
myPortal
? 中徘徊
- 另一个问题是脚本可能会失败(例如由于错误的凭据),而 Jenkins 作业不会失败。
我是 Jenkins 的 Tomcat-plugin 的 ware,但是这个 (a) 还要求 Tomcat-manager 是 运行 和 ( b) 我无法使用 Jenkins Choice 参数 重新部署($ServerURL
和 %ServerURL
都不起作用)这似乎是 Jenkins issue不可能使用参数化容器。
以下是最相关的相关帖子,但它们没有回答我的问题:
- Cannot successfully deploy war file in tomcat using jenkins
- Re-deploying a "versioned" war file from Jenkins to Tomcat fails
- Jenkins auto deploy tomcat 7
仅作记录:我们目前使用的解决方法是让其他一些软件进行部署。这样做的原因不是上述安全问题,而是我们的客户要求使用他们选择的专有软件打包服务 XYZ。 Jenkins 现在所做的就是使用该软件打包服务的 API 上传 WAR 文件。
我很欣赏这是一个较旧的 post 但我已经在 unix 服务器上使用 Jenkins 和 curl 使其工作...