归档/恢复所选jenkins作业的最佳方法是什么

时间:2015-08-04 09:45:26

标签: jenkins jenkins-plugins

我想知道存档未使用的作业的最佳方法是什么。是否有任何插件可以让我们存档选定的Jenkins作业,如果我们感觉到他们的要求,可以在以后恢复它们。 现在我正在复制作业文件夹并在删除作业日志后对其进行归档。我要将此目录恢复到Jenkins的作业目录。

2 个答案:

答案 0 :(得分:7)

Shelve Project plugin就是这样做的。

来自维基页面:

  

此插件可让您“搁置”项目,以便轻松复活。当你搁置一个项目时,它将从项目列表中消失而不是被删除,数据被存档到一个zip文件并存储在服务器上[...]这允许管理员复活它后面。

答案 1 :(得分:1)

我不知道最好的答案,但我已经创建了一个python脚本来完成这项工作, 你可以得到相同的 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>