I need to setup a job that builds any copy of the trunk made to a specific SVN repository folder. Whenever someone creates a new branch in that specific folder, that branch should be checked out, built, and the tests run. Branches will accumulate in that specific folder and tests take quite a while (among others they employ external hardware), so it's not feasible to just build every branch found there every time a new one is added. Instead, the job will have to only built the branch that was newly added.

So what I need is this:

  • monitor an URL (an_svn_repo.com/path_to_project/some_branch_folder) for changes
  • if a new folder has been created under the URL (an_svn_repo.com/path_to_project/some_branch_folder/new_stuff) , check out the new folder (some_branch_folder/new_stuff, but not some_branch_folder)
  • execute the build script in that folder

I have some ideas about how to approach that, but they are wildly different and I have no idea how feasible they are, so I'd like your input on this.

One way would be to check which sub-folder has the most recent changes and call the build script in that one. (But what if two branches are created at nearly the same time?) Another could be to store some information somewhere about what branches have been built and only build new ones. (But I have no idea whether Jenkins or a plugin has any means to store information between job invocations.) Also, a successful build of a branch could set a revision property on that branch, which Jenkins might then be able to ignore. Or I employ build parameters and start the job from a script.

I could just keep a script under an_svn_repo.com/path_to_project/some_branch_folder which does the necessary work, but it seems better to do most of the work in Jenkins itself, if possible.

What's your ideas?

有帮助吗?

解决方案

Take a look at the Build with Parameters plugin. I've used that before to do something like this. We had a site that insisted that each feature and bug fix had to be a different branch, so we defined a branch build that used the Build with Parameters plugin to specify the branch to build.

All you have to do is define a Subversion post-commit hook that fires off the build for the project when a branch it is on is created or modified. It's a fairly straight forward trigger.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top