Hudson plugins for visual svn
Problem
I have a hudson build server set up on a windows server 2008. We want to be able to commit to a repository and after the commit succeeds we want visual svn server to send a message or a trigger to the hudson build server to let it know it needs to execute a build. We want it to build only when someone does a commit so we don't want to poll svn constantly because its not necessary.
Question
Is there a plugin for visual svn that can automatically send a message to hudson or is there a better way of doing this without using wget? I've tried using wget on the hudson build url in the post commit hook of visual svn server but I realized that the post commit hooks can only be set for the entire repository and not individual projects in visual svn ser开发者_开发技巧ver, so if we made a small change to a different project in the repository its going to tell hudson it needs to build even though no changes have occurred in the project that is linked with hudosn...
How about let Hudson figure that one out. Hudson can poll the repository (only the URL of your project) to find out if there are changes and build only if changes are detected.
I agree with @Peter_Schuetze, let Hudson figure this out. It's not worth optimizing this unless you really see a problem.
You can use the post-commit hook to push Hudson and "Hudson will then check [the changes] against all the jobs that have a polling configured, and schedule the builds accordingly."
the post commit hooks can only be set for the entire repository and not individual projects
True. If you're really concerned though, in the post-commit hook, you could examine the changed directories before pinging Hudson, something like:
changes=`svnlook dirs-changed -r $REV $REPO`
case $changes in
my_project/*)
# ping Hudson
;;
esac
To me, it sounds like too much work to keep the post-commit hook up to date.
If you want to trigger builds only for certain projects, the most efficient way is to write the logic into your svn post-commit hook. This avoids the needless traffic of polling, and it triggers jobs only when the desired project is changed. The below example is used in our VisualSVN Server instance.
set repos=%1
set rev=%2
FOR /F "tokens=*" %%k IN ('svnlook dirs-changed "%repos%" -r %rev% 2^>NUL') do (
set Changed_Project=%%k
)
set Changed_Project=%Changed_Project:~9,9%
if "%Changed_Project%" == "Project_A" goto Actions_For_Project_A
:Actions_For_Project_A
curl -X POST "http://JenkinsVM:8080/job/Job_Name/build?&token=TOKEN_NAME
The above lines assume the project is under /branches/Project_A. For a different location you will need to adjust the strings start and length values. It also assumes that curl is in your set path and that you have created the authentication token in your Jenkins job.
精彩评论