I need to have a more intelligent post-commit script.
If a commit message states something like "Adding Revision-v.10.3 production", an ssh command needs to be executed.
Is it possible to do this with post-commit?
I need to have a more intelligent post-commit script.
If a commit message states something like "Adding Revision-v.10.3 production", an ssh command needs to be executed.
Is it possible to do this with post-commit?
There is no easy way to get the commit message from the SVN post-commit
hook. You can ask svn log
for the message, and then parse it out.
MESSAGE=$(/usr/bin/svn log "$1" -r HEAD --limit 1 --incremental | sed '1,3d')
From: here
To get the commit message from post-commit
use this:
MESSAGE=$(svnlook propget --revprop -r $REV $REPOS_PATH svn:log)
NO! NO! NO!
The last thing you should be doing is executing an ssh
on a post commit!
I'm not sure what your intentions are, and I assume them to be honorable. However, remember that Subversion won't return control to the client until the post-commit hook finishes executing. If your ssh
command takes just ten seconds to execute, then the user is seeing that svn commit
hanging there for ten seconds before they can do anything.
In those ten seconds, the user will develop a seething hatred of you, the company, and Subversion. They will become embittered shells of their former selves, and it will be your fault! Do you want that guilt hanging over your head? Didn't think so.
The best solution is to use a continuous build server like Jenkins and have that do your SSH command. It can take the results of the command, and if it fails, emails the results to the developer and their team. Jenkins is extremely easy to setup and use, and doing this through Jenkins (i.e., the correct way) shouldn't take more than a few hours (at most) to do.
Thus, the users commits won't be hanging there, yet they'll still get the information they need. And, since you have it tied to Jenkins, you'll probably find all sorts of plugins to Jenkins that do all sorts of marvelous things you didn't think possible. You'll be a hero and revered as a god. Isn't that better than seething hatred?
The choice is yours.
(By the way, you can get the commit message by doing a svn propget --rev-prop -r $REV svn:log
)
Just an FYI, what i just setup was a php script to execut on post-commit. If you're comfortable with PHP, this would give you a lot of control, and the possibility to run ssh command. I've outlined it here: https://stackoverflow.com/a/10146169/654235