What is the best way to archive / restore selected jenkins job?

I was wondering what is the best way to archive unused work. Is there any plugin that allows us to archive selected Jenkins jobs and restore them later if we feel a need for them. At the moment I am copying the job folder and archiving it after deleting the job logs. and to restore, I restore this directory back to the jobs directory in Jenkins.

+3


source to share


2 answers


The Shelve project plugin does just that.

From the wiki page:



This plugin allows you to "defer" projects so that they can be easily resurrected. When you postpone a project, it will disappear from the project list [...] instead of being deleted, the data is zipped in a zip file and saved on the server [...] This allows the administrator to resurrect it later.

+6


source


I don't know the best answer, but I 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>
      

Run code


+1


source







All Articles