Jakob
Jakob

Reputation: 1540

Post-receive hooks and Jenkins on Windows

I've got a problem with post-receive hooks and Jenkins integration. I've added a file called post-receive in the hooks-directory of the GIT-repository. The file contents are:

#!C:/Program\ Files/Git/usr/bin/sh.exe
echo "Post-receive started..."

curl.exe --user Jakob:tempPassword --url "http://localhost:8080/job/TestJob/build?token=ebcc64cb8315211c5287b20b3fdd7190"

echo "Post-receive ended..."

And on the Jenkins side I have a job for this token. I'm running Jenkins and the GIT-repos on a Windows 10 machine.

Now to the problem. If I execute the above command locally in a git bash shell everything is executed and the Jenkins build is initiated. All is fine.

If I however commit/push something to the GIT-repo, I can see that the post-receive-hook is executed (as I see it in the tortoisegit window), but the jenkins job is not executed!

enter image description here

What can the problem be?

Upvotes: 2

Views: 671

Answers (1)

Jakob
Jakob

Reputation: 1540

I've been struggling with this for two days, and just after posting my question I found a solution. I re-configured Jenkins to use the ip-address of the NIC in the machine (instead of localhost I used for example 192.168.1.55) and updated the sh-script to:

#!C:/Program\ Files/Git/usr/bin/sh.exe
echo "Post-receive started..."

curl.exe --user Jakob:tempPassword --url "http://192.168.1.55:8080/job/TestJob/build?token=ebcc64cb8315211c5287b20b3fdd7190"

echo "Post-receive ended..."

and now it works just fine!

Upvotes: 2

Related Questions