[Qa-jenkins-scm] [jenkins.debian.net] 01/01: only updates job when there have been changes

Holger Levsen holger at moszumanska.debian.org
Thu May 14 12:41:58 UTC 2015


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch master
in repository jenkins.debian.net.

commit a88b0f52a696e183e760f7d77e1548b4b07cb2da
Author: Holger Levsen <holger at layer-acht.org>
Date:   Thu May 14 14:41:38 2015 +0200

    only updates job when there have been changes
---
 update_jdn.sh | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/update_jdn.sh b/update_jdn.sh
index a7e824b..5130b4b 100755
--- a/update_jdn.sh
+++ b/update_jdn.sh
@@ -256,14 +256,24 @@ explain "Updated user content for Jenkins."
 # run jenkins-job-builder to update jobs if needed
 #     (using sudo because /etc/jenkins_jobs is root:root 700)
 #
+STAMP=/var/log/jenkins/jobs-updated.stamp
 cd /srv/jenkins/job-cfg
 for metaconfig in *.yaml.py ; do
-	python $metaconfig > ${metaconfig%.py}
+	python $metaconfig > $TMPFILE
+	if ! $(diff $metaconfig $TMPFILE > /dev/null) ; then
+		cp $TMPFILE ${metaconfig%.py}
+	fi
 done
 for config in *.yaml ; do
-	sudo jenkins-jobs update $config
+	if [ $config -nt $STAMP ] || [ ! -f $STAMP ] ; then
+		sudo jenkins-jobs update $config
+	else
+		echo "$config has not changed, nothing to do."
+	fi
 done
 explain "Jenkins jobs updated."
+touch $STAMP	# so on the next run, only configs newer than this file will be updated
+rm -f $TMPFILE
 
 #
 # crappy tests for checking that jenkins-job-builder works correctly

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list