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 when executed from the commandline.
Following is my groovy script.
#!/usr/bin/env groovy
def repoUrl= "https://gitblit.myhost.com/git/" + repository + ".git"
json='{"repository":{"url":"'+repoUrl+'"}}'
def response = "curl -v -k -X POST -H \"Content-Type: application/json\" -d '${json}' https://username:[email protected]:9443/restendpoint".execute().text
println response
repository is passed by gitblit to this script and I have verified it.
Can somebody help me with this.
I couldn't reproduce your problem with your example, but i will try a wild guess:
First, use the list execute()
version, so you don't have problems with tokens:
process = [ 'bash', '-c', "curl -v -k -X POST -H \"Content-Type: application/json\" -d '${json}' https://username:[email protected]:9443/restendpoint" ].execute()
Second, read both error and output from the process:
process.waitFor()
println process.err.text
println process.text
The err
may give out what is going on