{jenkins-plugin-info:shelve-project-plugin|sourceDir=shelve-project-plugin-plugin}

This plugin lets you shelve projects so that they can easily be resurrected.

"Shelving a project" is like deleting a project into a recycle bin. When you shelve a project, it'll disappear from the list of projects and become inaccessible from Jenkins, just like how it goes when a project is deleted, with one difference — instead of getting deleted, the data is archived into a zip file and stored on the server. This allows the administrator to resurrect it later (aka unshelving), in an unlikely event that the job turned out to be necessary.

This feature is convenient when you have lots of old jobs lying around, and you are 99% sure you won't need them but you can't rule out 1% possibility that you might find them necessary later.

Usage

When you install this plugin, you get "shelve project" in each job page, as follows:

You can click this icon and shelve the project. The shelved projects can be resurrected from the Jenkins top page, with the following UI:

Security

If security settings are enabled in Jenkins, shelving a project requires DELETE permissions and unshelving a project requires CREATE permissions.

Known issue and workaround

There is a currently a known issue in Core, making the tar function breaking the symlinks. Sadly, the Shelve Pipeline Plugin is using this tar function, and therefore the symlinks are lost during the shelving/unshelving process.

Up until Jenkins 2.90, this was mainly hidden from the end user, as Jenkins was silently fixing the symlinks during a build. But since this version, some changes made this issue visible.

This means that, when you unshelve a job, you will see a stack trace like this in all your build logs:

ln builds/lastSuccessfulBuild ***/jenkins-home/jobs/toto/lastSuccessful failed
java.nio.file.DirectoryNotEmptyException: ***/jenkins-home/jobs/toto/lastSuccessful
	at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:242)
	at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)
	at java.nio.file.Files.deleteIfExists(Files.java:1165)
	at hudson.Util.createSymlink(Util.java:1333)
	at hudson.model.Run.createSymlink(Run.java:1866)
	at hudson.model.Run.updateSymlinks(Run.java:1847)
	at hudson.model.Run.execute(Run.java:1725)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:421)

While this won't affect the output of your build, this is far from convenient. A workaround for this issue is to manually delete the wrongly created files using something like:


First make a dry run to ensure the script is not deleting something it shouldn't:


find ${JENKINS_HOME}/jobs/ -type d \( -name lastFailedBuild -o -name lastSuccessfulBuild -o -name lastUnsuccessfulBuild -o -name lastStableBuild -o -name lastUnstableBuild -o -name lastFailed -o -name lastSuccessful -o -name lastUnsuccessful -o -name lastStable -o -name lastUnstable \)


Then, do the real cleaning:

find ${JENKINS_HOME}/jobs/ -type d \( -name lastFailedBuild -o -name lastSuccessfulBuild -o -name lastUnsuccessfulBuild -o -name lastStableBuild -o -name lastUnstableBuild -o -name lastFailed -o -name lastSuccessful -o -name lastUnsuccessful -o -name lastStable -o -name lastUnstable \) -exec rm -rfv "{}" \;


Version History

Unreleased

Version 2.2 (2018-11-13)

Version 2.1 (2018-07-20)

The way a project is backed up has now changed from zip to tar. This is mainly a detail of implementation for you as your currently shelved project can still be unshelved from zip files.

However if you have some sort of automation on the shelved project directory (backup of the projects elsewhere for instance), you might need to adapt your script to look for tars instead of zips.


Version 2.0 (2018-07-15)

Version 1.5 (2014-04-18)

Version 1.4.4 (2013-07-29)

Version 1.3 (2011-08-06)

Version 1.2 (2011-02-08)

Version 1.1 (2010-11-05)

Version 1.0 (2010-10-18)

Version 0.3 (2010-02-27)

Version 0.2 (2010-01-25)

Version 0.1 (2010-01-05)

Todo