<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>Days of ... (continuous integration)</title><link>http://blog.yellowbluebus.com</link><description>Useful technology stuff</description><lastBuildDate>Wed, 03 Jul 2013 12:03:00 GMT</lastBuildDate><generator>nikola</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Revised: Save Hudson/Jenkins settings and installed plugins</title><link>http://blog.yellowbluebus.com/posts/wordpress20130423revised-save-hudsonjenkins-settings-and-installed-plugins.html</link><description>&lt;html&gt;&lt;body&gt;&lt;p&gt;&lt;/p&gt;
&lt;pre&gt;
.. code:: bash
 #!/bin/bash
&lt;p&gt;JENKINS_FOLDER="/shared/jenkins"&lt;/p&gt;
&lt;p&gt;DEST_FOLDER="/jenkins-backup"&lt;/p&gt;
&lt;p&gt;if [ ! -d "${DEST_FOLDER}" ]; then
  mkdir -p ${DEST_FOLDER}
fi&lt;/p&gt;
&lt;p&gt;if [ ! -d "${DEST_FOLDER}/jobs" ]; then
  mkdir -p ${DEST_FOLDER}/jobs
fi&lt;/p&gt;
&lt;p&gt;cd ${JENKINS_FOLDER}&lt;/p&gt;
&lt;p&gt;pwd&lt;/p&gt;
&lt;p&gt;/usr/bin/rsync -v -a --relative --checksum ./*.xml ${DEST_FOLDER}&lt;/p&gt;
&lt;p&gt;/usr/bin/rsync -v -a --relative --checksum ./plugins/ ${DEST_FOLDER}/&lt;/p&gt;
&lt;p&gt;cd ${JENKINS_FOLDER}/jobs&lt;/p&gt;
&lt;p&gt;pwd&lt;/p&gt;
&lt;p&gt;find . -maxdepth 2 -name "config.xml" -print0 | /usr/bin/rsync -v -a --relative --checksum --files-from=- --from0 ./ ${DEST_FOLDER}/jobs/&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</description><guid>http://blog.yellowbluebus.com/posts/wordpress20130423revised-save-hudsonjenkins-settings-and-installed-plugins.html</guid><pubDate>Tue, 23 Apr 2013 07:42:07 GMT</pubDate></item><item><title>SOLVED: Save Hudson configs to Subversion. Automatically.</title><link>http://blog.yellowbluebus.com/posts/wordpress20101013solved-save-hudson-configs-to-subversion-automatically.html</link><description>&lt;html&gt;&lt;body&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;I decided to save Hudson configs to Subversion repository just in case something goes wrong with the server later and would need to restore all projects. A bit of googling first, found that there are plugins to to a backup of workplaces and configs. But why would I need to have them? I am on Solaris, so I can create the same by my own hands. Here are my requirements:
&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Backup should be a job within Hudson - since Hudson is a best cron you could find and I already have it&lt;/li&gt;
    &lt;li&gt;Backup should automatically discover added jobs and add then into Subversion - thus I will forget about it forever, no maintenance required&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Simples! So I created a custom build job within Hudson, pointed it to a Subversion location, where I will store backups and backup shell script, which will gather all Hudson configs and deal with Subversion. I told Hudson that I don't want to create subfolder for a project within its workplace. Then I set to execute script this way: &lt;code&gt; ${WORKPLACE}/hudsonbackup.sh &lt;/code&gt;Here is the script itself:&lt;/p&gt;
&lt;p&gt;&lt;code lang="bash[lines]"&gt;#!/bin/bash&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;SRC_FOLDER=${WORKSPACE}&lt;/p&gt;
&lt;p&gt;SVN_PARAMS="--config-dir /.subversion/ --non-interactive --trust-server-cert --username f_tc_ci1 --password &lt;strong&gt;*&lt;/strong&gt;"&lt;/p&gt;
&lt;p&gt;SVN_COMMAND="/opt/csw/bin/svn"&lt;/p&gt;
&lt;p&gt;JOBS=&lt;code&gt;ls -al /.hudson/jobs/|grep -v job1|grep -v job2|awk ' NR&amp;amp;gt;3 {print $9}'&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;CURR_FOLDER=&lt;code&gt;pwd&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;echo "Copying Hudson configs"&lt;/p&gt;
&lt;p&gt;cp /.hudson/*.xml ${SRC_FOLDER}&lt;/p&gt;
&lt;p&gt;echo "Done."&lt;/p&gt;
&lt;p&gt;cd ${SRC_FOLDER}&lt;/p&gt;
&lt;p&gt;echo "Processing Hudson jobs"&lt;/p&gt;
&lt;p&gt;for JOB in ${JOBS}&lt;/p&gt;
&lt;p&gt;do
  echo "Processing ${JOB}"
  if [ ! -e ${JOB} ]
  then
    echo "New job. Creating folder and adding it to SVN"
    mkdir  ${JOB}
    ${SVN_COMMAND} add ${SVN_PARAMS} ${JOB}  &lt;br&gt;
    SVN_COMMENT="${SVN_COMMENT} Added ${JOB}"
  fi  &lt;/p&gt;
&lt;p&gt;echo "Saving ${JOB}/config.xml"
  if [ -e ${JOB}/.svn ]
  then
    if [ -e ${JOB}/config.xml ]
    then
      # config.xml already exist - don't need to add it to subversion
      cp /.hudson/jobs/${JOB}/config.xml ${JOB}/
    else
      echo "New job - new config.xml"
      cp /.hudson/jobs/${JOB}/config.xml ${JOB}/
      ${SVN_COMMAND} add ${SVN_PARAMS} ${JOB}/config.xml
    fi
  else
    echo "Problem creating and adding folder to Subversion"
    exit 1
  fi
done&lt;/p&gt;
&lt;p&gt;echo "Job processing is done. Committing..."&lt;/p&gt;
&lt;p&gt;${SVN_COMMAND} ci ${SVN_PARAMS} -m "Config saved by Hudson. ${SVN_COMMENT}"&lt;/p&gt;
&lt;p&gt;echo "All done."&lt;/p&gt;
&lt;p&gt;Note 1: My Subversion is on HTTPS server with the self-signed certificate, so I have to tell Subversion client to trust it explicitly. Its on line 4. On line 5 I constructed the path to Subversion client because Hudson executing shell scripts with quite limited PATH. Note 2: I need to ignore some jobs, so I added them on line 6. Also on this line I have hardcoded Hudson location ("/.hudson") - it needs to be changed if your Hudson somewhere else. After all that I set this job to execute daily. It works!&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</description><guid>http://blog.yellowbluebus.com/posts/wordpress20101013solved-save-hudson-configs-to-subversion-automatically.html</guid><pubDate>Wed, 13 Oct 2010 07:51:41 GMT</pubDate></item></channel></rss>