jenkins迁移job

Jenkins迁移job

 转自:http://www.cnblogs.com/topplay/p/3899330.html
说明:从一个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.

具体步骤以下:
一、首先确认Jenkins的job存放目录。
以管理员帐号登陆Jenkins,点击“系统管理/系统设置”,确认jenkins工做目录。
本例中Jenkins A的工做目录为/home/.jenkins,Jenkins B的工做目录为/root/.jenkins。
 
二、接下来,迁移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/
 
三、接着,在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. 
 
 
点击上述红框中的“读取设置”按钮后,显示以下信息:


四、最后,验证B上是否已经加载了迁移进来的新job,同时须要对job进行配置。
1)登陆到Jenkins B后,发现A上的jobs已经正确迁移进来。以下:
 
五、注意事项
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.  
相关文章
相关标签/搜索