詹金斯管道还没有完成Tomcat战争部署

时间:2018-08-14 13:43:44

标签: maven tomcat curl jenkins jenkins-pipeline

我想使用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部署结果即可进入下一阶段。有什么快速的解决方案可以解决此问题吗?

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

对此进行快速(但非常糟糕)的修复是在代码中放置一段时间。 sleep(30) 这将使curl产生浪费时间,将您的jar提交/上传到目标服务器。 **请勿在生产环境中依赖**