-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbackup_jenkins.sh
38 lines (30 loc) · 996 Bytes
/
backup_jenkins.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
# Thank you
# http://jenkins-ci.org/content/keeping-your-configuration-and-data-subversion
# for the inspiration.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $DIR/common.sh
echo_task "copying xmls"
cp -v $JENKINS_DIR/*.xml $BACKUP_DIR
echo_task "copying job configurations"
for DIR in `ls -p $JENKINS_DIR/jobs | grep "/" | xargs`
do
mkdir -p $BACKUP_DIR/jobs/$DIR
cp -v $JENKINS_DIR/jobs/$DIR/*.xml $BACKUP_DIR/jobs/$DIR
done
echo_task "copying job configurations"
for DIR in `ls -p $JENKINS_DIR/jobs | grep "/" | xargs`
do
mkdir -p $BACKUP_DIR/jobs/$DIR
cp -v $JENKINS_DIR/jobs/$DIR/*.xml $BACKUP_DIR/jobs/$DIR
done
echo_task "copying users and user content"
cp -vr $JENKINS_DIR/users $BACKUP_DIR/
cp -vr $JENKINS_DIR/userContent $BACKUP_DIR/
echo_task "committing to git"
cd $BACKUP_DIR
git add .
git commit -m "automated commit of jenkins configuration on [$(date)]."
git push $GIT_REMOTE $GIT_BRANCH
cd $OLDPWD
alert "done! \o/"