我已经看过几种备份Jenkins主目录的方法。其中一个更有趣(而且看起来是完整的)的方法是配置Jenkins作业,它将Jenkins主目录备份到源代码管理。
在备份过程中,我试图弄清楚到底需要执行什么(通过'execute‘构建步骤)。我们目前使用BitBucket进行源代码管理(GIT),并有一个Jenkins和四个Jenkins /从构建节点。
先决条件
备份Jenkins的步骤
因此,对于那些以前使用这种方法对Jenkins进行自动备份的人,我有几个问题:
任何其他建议也是受欢迎的。
发布于 2017-07-25 13:16:23
在工作中,您可以添加BitBucket凭据。但是我所做的就是让作业文件夹成为一个.git回购,并且我经常手动提交它。
您还可以为您运行我在网上找到的bash脚本:巴什脚本来完成这个任务。
#!/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 masterhttps://stackoverflow.com/questions/44766649
复制相似问题