说明:从一个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/Sudley/Jenkins,Jenkins B的工作目录为 /home/Sudley/Jenkins。
2、接下来,迁移jobs目录。
登录Jenkins A服务器,进入工作目录,压缩jobs目录,并复制到B:
cd /home/Sudley/Jenkins
tar -czvf jobs.tar.gz jobs
scp -f jobs.tar [email protected]: /home/Sudley/Jenkins
3、接着,在B上解压jobs.tar到jobs目录,并重启Jenkins服务器B。注意:重启不是必须的。
1)通过重启hudson来加载新迁移的job:
cd /home/Sudley/Jenkins
tar -zxvf jobs.tar
tomcat方式安装的通过重启tomcat服务来重启Jenkins
cd /opt/tomcat/tomcat7/bin/
./shutdown.sh
./startup.sh
其他方式安装通过运行Jenkins的重启进程重启
service jenkins restart
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.