Folders Plugin Now with Support for Moving Items

Written by: Stephen Connolly

The CloudBees Folders plugin provides a feature that is needed by so many people that once we had the basic Folders feature implemented we just had to release it... even though it was missing a key feature... namely the ability to move jobs and folders.

It's not like we didn't have a solution... more that our solution was... ahem... how can I put it... crap! The solution basically boiled down to the following:

  1. Stop Jenkins

  2. On the File system move the directories where you want them to go

  3. Start Jenkins again

Not so bad if you have a small Jenkins instance, but people who need folders typically have a rather large Jenkins instance.

Well, no more the stop/start solution, today we can announce the ability to move items between folders.

Why did it take so long? Well, there were a number of technical problems that had to be addressed; for example, you should not move a folder while there are jobs in progress within the folder. Also, we need to take into account the fact that Jenkins is a multi-user system, so what happens when two users try to move folders at the same time? For example, I am trying to move job A into folder B and you are trying to move folder B into folder C.

So, our solution works as follows:

  • You submit a move request to Jenkins for the item you want to move.

  • The move request goes into the Jenkins queue.

  • When there are move requests on the Jenkins queue, a special temporary node is added to Jenkins to handle the move request. This node will only process move requests and can only handle one move request at a time, thereby removing race conditions.

  • When a move request is being processed:

    • Any of the jobs within the item are temporarily disabled to ensure that no new builds are started

    • Any in-progress builds block the move until they complete

    • The file system move is made (this will be retried a number of times to handle the case of Windows file locking preventing the move)

    • The Jenkins item's parent is adjusted so that the configuration does not need to be reloaded

  • Once all move requests have been processed, the special temporary node is removed.

All this is available now if you upgrade to version 3.2 of the CloudBees Folders plugin. And if you haven't got the CloudBees Folders plugin, it is available for free (registration required) if you install the CloudBees Free Enterprise Plugins.

--Stephen Connolly
CloudBees
cloudbees.com

Stay up to date

We'll never share your email address and you can opt out at any time, we promise.