我已经看了几种备份Jenkins主目录的方法。这样做的一个更有趣(并且看似完整)的方法是配置Jenkins作业,该作业将Jenkins主目录备份到源代码控制。
我试图在备份过程中清楚地了解需要执行的操作(通过'执行shell'构建步骤)。我们目前使用BitBucket进行源代码控制(GIT),并有一个Jenkins Master和四个Jenkins代理/从属构建节点。
先决条件:
备份Jenkins的步骤:
因此,对于那些在Jenkins自动备份之前使用过此方法的人,我有几个问题:
欢迎任何其他建议。
答案 0 :(得分:0)
在您的工作中,您可以添加BitBucket凭据。但我为我做的是将jobs文件夹作为.git repo,我经常手动提交它。
你也可以为你运行我在网上找到的bash脚本做一个工作:Bash Script
#!/bin/bash
# Setup
#
# - Create a new Jenkins Job
# - Mark "None" for Source Control Management
# - Select the "Build Periodically" build trigger
# - configure to run as frequently as you like
# - Add a new "Execute Shell" build step
# - Paste the contents of this file as the command
# - Save
#
# NOTE: before this job will work, you'll need to manually navigate to the $JENKINS_HOME directory
# and do the initial set up of the git repository.
# Make sure the appropriate remote is added and the default remote/branch set up.
#
# Jenkins Configuraitons Directory
cd $JENKINS_HOME
# Add general configurations, job configurations, and user content
git add -- *.xml jobs/*/*.xml userContent/*
# only add user configurations if they exist
if [ -d users ]; then
user_configs=`ls users/*/config.xml`
if [ -n "$user_configs" ]; then
git add $user_configs
fi
fi
# mark as deleted anything that's been, well, deleted
to_remove=`git status | grep "deleted" | awk '{print $3}'`
if [ -n "$to_remove" ]; then
git rm --ignore-unmatch $to_remove
fi
git commit -m "Automated Jenkins commit"
git push -q -u origin master