Perfectly working curl command fails when executed in a groovy script

后端 未结 4 729
不思量自难忘°
不思量自难忘° 2021-02-02 11:08

I have a post commit hook (a groovy script) in gitblit to invoke a REST endpoint. In this script I am executing a curl command. But it seems to fail. The curl command works fine

4条回答
  •  抹茶落季
    2021-02-02 11:38

    I was able to get this working by passing all the string in my curl command in an array. Following is how I did it.

    def response = ["curl", "-k", "-X", "POST", "-H", "Content-Type: application/json", "-d", "${json}", "https://username:password@myhost.com:9443/restendpoint"].execute().text
    

提交回复
热议问题