I was wondering that what is the best way to archive your unused job.Is there any plugin which allows us to archive selected Jenkins jobs and restore them later if we feel their requirement. For now i am copying the job folder and archiving the same after removing job logs. and for restoration i am restoring this directory back to jobs directory in Jenkins.
The Shelve Project plugin does exactly this.
From the wiki page:
This plugin lets you "shelve" projects so that they can easily be resurrected. When you shelve a project, it'll disappear from the list of projects [...] 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.
I dont know the best answer but i have created a python script to do the job , You can get the same at https://github.com/thinkingmonster/pythonscripts
This module provides facility to take easy backup of Jenkins jobs which needs to be archived.It provided the facility where you can either provide a single jobname to be archived or multiple job names written inside a file and passing file path as an argument to the script.Script can be run as shown below.
<h6>How to use module </h6>
- Pull the files and place them at /opt
- TakeInput.py is the main file execute the same to start the program.
- Alternatively you can also create a softlink to the same in /bin and use soft-link as command.
```
python TakeInput.py -n <jobname>
```
<br>
<table style="width:100%">
<tr>
<th>Option</th>
<th>Explain</th>
</tr>
<tr>
<td>-h</td>
<td>Prints help menu</td>
</tr>
<tr>
<td>-n</td>
<td>Provide job name or full job name(absolute path) as input</td>
</tr>
<tr>
<td>-f</td>
<td>Provide input file path(absolute path)</td>
</tr>
<tr>
<td>-b</td>
<td>Provide backup location,ie location where you want the archived job to be placed<br>
default is /tmp location</td>
</tr>
<tr>
<td>-r</td>
<td>This option works when you want to restore an archived job back to the Jenkins<br> environment.You can provide absolute
path of job archive or absolute path of directory containing job archives for mass restore</td>
</tr>
</table>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With