詹金斯卷曲:(52)来自服务器的空回复

时间:2017-12-05 22:05:28

标签: tomcat docker curl jenkins

我正在做一个有几个阶段的声明性管道。在其中一个阶段中,我想在运行的docker上使用tomcat映像部署war文件。为此,我使用命令curl。但我总是在詹金斯身上得到以下错误:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0 15.7M    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (52) Empty reply from server

这是我的代码:

pipeline {
    agent any
    ....

            stage ('System test') {
            steps{
                bat 'docker run -d -p 9205:8080 tomcat:7.0.82'
                dir('some/dir/something'){
                    script{                             
                        bat 'curl -T "C:/path/to/solution.war" "http://tomcat:tomcat@localhost:9205/manager/text/deploy?path=/solution.war&update=true"'                                
                    }
                    input 'Do you want to proceed?'
                }
            }
        }

我已经尝试过的事情:

  • curl -L

  • netstat -a -p TCP -n | grep 3000(使用的端口)..查看是否没有多个连接

  • 使用凭据卷曲

1 个答案:

答案 0 :(得分:0)

看起来tomcat仅在容器内部监听127.0.0.1(localhost),而应该在0.0.0.0监听。

您是否尝试过使用以下命令在容器内卷曲

docker exec -it <container_name> curl 'curl -T "C:/path/to/solution.war" "http://tomcat:tomcat@localhost:8080/manager/text/deploy?path=/solution.war&update=true"'

如果这行得通,那么您必须将Tomcat配置为侦听所有IP

  1. 编辑tomcat/conf/server.xml
  2. 指定该连接器的绑定地址:
    <Connector 
        port="8080" 
        protocol="HTTP/1.1" 
        address="0.0.0.0"
        connectionTimeout="20000" 
        redirectPort="8443" 
      />
    

希望这会有所帮助。

相关问题