Jenkins clone jobs and change branch

I have a task that I want to realize with Jenkins, but I don't know how to do it.

I have a view full of jobs, all pointing to the same svn repo. Each job build one maven module present on the svn repo.
Once a year, we release a version, and therefore we create a new branch for the development on the future new version.
In Jenkins, it means that I want a view with all my jobs pointing on the released version branch, and a new view with the same jobs, but pointing on the future version branch.

I know that I can do that manually by cloning and then modify the branch for all the jobs, but I want to do that with the least number of actions possible (ideally one :-)).
I take a look at Jenkins built-in possibilities and in existing plugins, but I found nothing and I have no idea how to do it.
Is there a possibility to script that kind of job ? Or a plugin doing that ?

Thank you,

Seb

Upvotes: 0

Views: 493

Answers (1)

Bruno Lavit
Bruno Lavit

Reputation: 10382

I suppose your future versions are developed on the trunk. So the URL for these versions is always the same (ex: http://svn.yourcompany.com/project1/trunk).

I propose to group your trunk jobs in a dedicated folder using the CloudBees Folder plugin.

This plugin will group all your jobs in a physical folder in your Jenkins home folder (ex: jobs/trunk).

When you want to create the new jobs for the release branch, you write a script which:

  • Copy the jobs/trunk folder into jobs/release_2.0
  • Replace http://svn/.../trunk with http://svn/.../branches/2.0 (you can use a regexp to do that)
  • Rename all the jobs (you just need to add 2.0 at the end of all job names)
  • Reload the Jenkins configuration

It should work :)

Upvotes: 1

Related Questions