вторник, 25 июня 2013 г.

How to use Jenkins with 'SCM Sync configuration' plugin

The next instructions were checked for Ubuntu 12.04.


'SCM Sync configuration' plugin can be used to backup changes of Jenkins configuration after each 'save' action.
The next file is instruction how I did it.


#create_local_jenkins_config_repo.sh


#!/bin/bash

# This script has to be used with 'SCM Sync configuration plugin' of Jenkins
# This script will create '/var/lib/jenkins/jenkins-config-repo' directory
# where Git repo (bare) will be created for storing Jenkins' configs.

# If you want to place remote repository in some other place you should correct some commands in the file
# and in instructions below.
# ALARM. 'jenkins' user should have access rights to do changes in Git repository that specified in 'Repository URL'.

# After running this script go to Jenkins->Manage Jenkins->Configure System->SCM Sync configuration:
# - select 'Git'
# - Set 'Repository URL' = 'file:///var/lib/jenkins/config-backup-repository'
# - Click 'Save' button
# After that run the following commands
# - cd /var/lib/jenkins
# - chown -R jenkins:nogroup scm-sync-configuration  jenkins-config-repo
# - cd scm-sync-configuration/checkoutConfiguration
# - git config user.name "Jenkins"
# - git config user.email "jenkins@localhost"
# Now you will get

cd /var/lib/jenkins

if [ "$?" != "0" ]
then
 echo "Can't change directory to '/var/lib/jenkins'"
 echo $?

 exit 1
fi

mkdir /var/lib/jenkins/jenkins-config-repo

cd jenkins-config-repo
git init --bare
cd ..

mkdir temp_repo
cd temp_repo
git clone /var/lib/jenkins/jenkins-config-repo .
touch README
git add README
git commit -m "First commit"
git push -u origin master
cd ..



Комментариев нет:

Отправить комментарий