Question

We are using uberSVN installed on linux. In the repository "R" we have different branches and I need to trigger the jenkins job for a commit on a specific branch "B". In the ....repository/R/hooks/ there is file named post-commit. The file content is below:

REPOS="$1"
REV="$2"

wget "http://jenkinsurl/job/project_r/build?tokten=r_token"

The above script calls wget whenever repo has been commited. On the other hand, I want to trigger "the branch job" if and only if there is a commit on branch "B" not all repository. The jenkis url is below:

wget "http://jenkinsurl/job/project_r_b/build?tokten=r_b_token"

What is the proper way to do this?

Was it helpful?

Solution

You can call svnlook dirs-changed to get changed paths in the committed revision. Pipe this command's output to grep and search for "branches/b". If the output of the command has "/branches/b", then run the job. Exit, otherwise.

Check this question for the sample code: Post-commit hook failed (exit code 3) with output.

OTHER TIPS

You can use the Poll-SCM option in the Jenkin job. Give the poll interval as every minute * * * * * or you can set the poll interval to 5 or 10 minutes. With each poll this will check whether there is change in your svn branch. If there is change the build will get triggered, else nothing. This option you can find in the project configuration page under the tab Build Triggers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top