Using the following code:
This git post-receive hook script queries the latest commit, gets the
revision changes, and then passes that payload (via json) to a
net/https POST call. I setup our Integrity CI server with a self-signed certificate and HTTP basic authentication.
Net::HTTP::Post.new instantiation group handles populating the basic
authentication information and putting the payload into the form data
of the request. The Net::HTTP.new group handles telling the request
that it will be via SSL (443) and to not verify the SSL certificate
(since I’m using a self-signed certificate; otherwise, I’d get a
warning and kill my automation process)
The other important part is the “if pid = fork”. The ruby fork
command allows code to happen in the background, in the case the POST
call, and therefore make the call synchronous. Otherwise, when the
developers commit their code to the repository, they will have to wait
for the build to finish before their prompt will be returned to them.
fork will return zero (0) if it fails to create the background process.
still checking whether the zombie process warning in the rdoc (for the
fork command) is a problem. I’ll update this if it is.
The last line is notification for the user so they know what’s going on. Always good to keep the user in the loop. :)
Post Footer automatically generated by Add Post Footer Plugin for wordpress.