Jenkins迁移job

说明:从一个Jenkins服务器A将现有job迁移到另外一个Jenkins服务器B。
方法:You can copy or move build jobs between instances of projects simply enough by copying or moving the
build job directories to the new Jenkins instance.

具体步骤如下:
1、首先确认Jenkins的job存放目录。
以管理员账号登录Jenkins,点击“系统管理/系统设置”,确认jenkins工作目录。
本例中Jenkins A的工作目录为/home/.jenkins,Jenkins B的工作目录为/root/.jenkins。

2、接下来,迁移jobs目录。
登录Jenkins A服务器,进入工作目录,压缩jobs目录,并复制到B:
  1. cd /home/.jenkins
  2. tar -czvf jobs.tar.gz jobs
  3. scp -f jobs.tar root@BIP:/root/.jenkins/

3、接着,在B上解压jobs.tar到jobs目录,并重启Jenkins服务器B。注意:重启不是必须的。
1)通过重启hudson来加载新迁移的job:
  1. cd /root/.jenkins
  2. tar -zxvf jobs.tar
本例通过重启tomcat服务来重启Jenkins,其他通过jar运行Jenkins的重启进程即可。
  1. cd /opt/tomcat/tomcat7/bin/
  2. ./shutdown.sh
  3. ./startup.sh
2)不需要重启:
just go to the Manage Jenkins screen and click on Reload Configuration From
Disk. This will load the new jobs and make them immediately visible on the Jenkins dashboard. 
 

点击上述红框中的“读取设置”按钮后,显示如下信息:


4、最后,验证B上是否已经加载了迁移进来的新job,同时需要对job进行配置。
1)登录到Jenkins B后,发现A上的jobs已经正确迁移进来。如下:


5、注意事项
1)修改job的配置:
由于之前job设置是在Jenkins A的某个节点上执行,所以如果想让它在Jenkins B的某个节点上执行,则需要检查job的配置“Restrict where this project can be run”,设置job运行的节点。


2)插件:如果Jenkins A上安装了插件,而B没有,则迁移过来的任务可能也需要安装A上的插件。
There are a few gotchas, however. If you are migrating your jobs to a brand new Jenkins configuration,
remember to install, or migrate, the plugins from your original server. The plugins can be found in
the plugins directory, so you can simply copy everything from this directory to the corresponding
directory in your new instance.  





posted @ 2014-08-08 14:39  ajupiter  阅读(27630)  评论(0编辑  收藏  举报