I'm trying to figure out how to write a pre-commit hook for Git
that checks the status of my Hudson
build. If the previous build failed, it should disallow anyone from committing without first writing a specific line, e.g. "fixed build."
EDIT:
The first answerer has provided one side of the coin: the Hudson API.
I now need the other side. How do I write the pre-commit hook in Git
?
Open a terminal window by using option + T in GitKraken Client. Once the terminal windows is open, change directory to . git/hooks . Then use the command chmod +x pre-commit to make the pre-commit file executable.
The pre-commit hook is run first, before you even type in a commit message. It's used to inspect the snapshot that's about to be committed, to see if you've forgotten something, to make sure tests run, or to examine whatever you need to inspect in the code.
Pre-commit detects problems before they enter your version control system, let's you fix them, or fixes them automatically. The power of the crowd. Easily use hooks other people have created in bash, R, Python and other languages.
Quick tip if you want to skip the pre-commit validations and quickly want to get a commit out there. To get your commit through without running that pre-commit hook, use the --no-verify option. Voila, without pre-commit hooks running!
As mentioned in this blog post, Hudson has a discoverable API, through its Remote Access API.
http://myhudson.example.com/job/MyJob/api
By using a combination of:
you can extract the status of the latest build.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With