I wanted to know how to execute a bash script in the local repo after pushing to github.
The bash script is located in the root of the folder. It can be moved around depending on where it is being called I guess. I have looked into git hooks but there is no post-push hook and I don't understand the other hooks very well.
I'm trying to call a jenkins build after the push. I have looked into ways of notifying jenkins after a push with post-receive url etc on github but nothing seems to work for me.
This is the script I'm trying to run:
#!/bin/bash/
java -jar jenkins-cli.jar -s http://localhost:8080/ build Test
Thanks! Varun
This is fairly easy. There is a script ready to run. You will have to modify .git/hooks/post-commit to find the script you need to run.
mv .git/hooks/post-commit.sample .git/hooks/post-commit
vim .git/hooks/post-commit
I found this at: git-scm.com: Git Hooks
If there is no .git/hooks/post-commit.sample
file, not a problem, just create .git/hooks/post-commit
from scratch (Remember to make the script executable with chmod +x
), for example:
#!/bin/sh
echo look at me I am the post-commit script
pwd
# call the script you want
Do a test commit and you should see the output of the script, right before the regular output of the commit.