【问题标题】:Jenkins pipeline not finish tomcat war deployJenkins 管道未完成 tomcat 战争部署
【发布时间】:2018-08-14 13:43:44
【问题描述】:

我想使用 Tomcat 管理器从 Jenkins 部署战争。 这是我从命令行执行的操作:

curl -v -u user:pasword -T target/app.war "http://host:8180/manager/text/deploy?path=&update=true"

这需要一点时间并且有效:

 * Hostname was NOT found in DNS cache
*   Trying ip...
* Connected to host.com (ip) port 8180 (#0)
* Server auth using Basic with user 'jenkins'
> PUT /manager/text/deploy?path=&update=true HTTP/1.1
> Authorization: Basic amVua2luczpLbzNEaUE=
> User-Agent: curl/7.38.0
> Host: host.com:8180
> Accept: */*
> Content-Length: 71682391
> Expect: 100-continue
> 
< HTTP/1.1 100 
* We are completely uploaded and fine
< HTTP/1.1 200 
< Cache-Control: private
< Expires: Thu, 01 Jan 1970 00:00:00 UTC
< Content-Type: text/plain;charset=utf-8
< Transfer-Encoding: chunked
< Date: Tue, 14 Aug 2018 13:18:22 GMT
< 
OK - Application déployée pour le chemin de contexte [/]
* Connection #0 to host host.com left intact

我的问题是当我在 Jenkins Pipeline 中执行此命令时:

    stage('Tomcat Deploy') {
       sh "curl -v -u user:password -T app.war http://host:8180/manager/text/deploy?path=&update=true"
   }

curl 命令未正确完成:

    + curl -v -u jenkins:pass -T app.war http://host:8180/manager/text/deploy?path=
* Hostname was NOT found in DNS cache
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying ip...
* Connected to host.com (ip) port 8180 (#0)
* Server auth using Basic with user 'jenkins'
> PUT /manager/text/deploy?path= HTTP/1.1
> Authorization: Basic amVua2luczpLbzNEaUE=
> User-Agent: curl/7.38.0
> Host: host.com:8180
> Accept: */*
> Content-Length: 71682391
> Expect: 100-continue
> 
< HTTP/1.1 100 
} [data not shown]
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage

它无需等待 curl 部署结果即可进入下一阶段。有什么快速的解决方案可以解决这个问题吗?

【问题讨论】:

  • 您确定不会上传吗? Jenkins 输出中的 [data not shown] 可能表明,Jenkins 只是隐藏了一些日志......

标签: maven tomcat curl jenkins jenkins-pipeline


【解决方案1】:

是的,战争没有上传。但我使用 --upload-file 选项解决了我的问题。现在詹金斯等待上传出席。谢谢。

【讨论】:

    【解决方案2】:

    一个快速(但非常糟糕)的解决方法是在您的代码中休眠一段时间。 sleep(30) 这将使 curl commad 有时间将您的 jar 提交/上传到目标服务器。 ** 不要在生产中依赖它 **

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-19
      • 2019-08-05
      • 2012-04-14
      • 1970-01-01
      • 1970-01-01
      • 2018-12-21
      • 1970-01-01
      • 2018-08-30
      相关资源
      最近更新 更多