[Qa-jenkins-scm] [jenkins.debian.net] 04/06: d-i: inject variables for later triggers

Holger Levsen holger at layer-acht.org
Mon Jul 18 17:59:28 UTC 2016


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 f7e88d07551f9c1c71ca72d8653e68cde1dbe883
Author: Philip Hands <phil at hands.com>
Date:   Mon Jul 18 13:58:12 2016 +0200

    d-i: inject variables for later triggers
    
    Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
 bin/d-i_build.sh              | 27 +++++++++++++++++----------
 bin/jenkins_master_wrapper.sh |  2 +-
 bin/jenkins_node_wrapper.sh   |  2 +-
 bin/lvc.sh                    |  8 ++++----
 job-cfg/d-i.yaml.py           | 12 +++++-------
 job-cfg/lvc.yaml              |  4 ++--
 6 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/bin/d-i_build.sh b/bin/d-i_build.sh
index e2af277..e076a70 100755
--- a/bin/d-i_build.sh
+++ b/bin/d-i_build.sh
@@ -46,23 +46,26 @@ replace_origin_pu() {
 
 iso_target() {
 	UI=$1 ; shift
-	echo "${ISO_DIR}/mini-${UI}$(replace_origin_pu "-" $PU_GIT_BRANCH).iso"
+	BRANCH=$1 ; shift
+	echo "${ISO_DIR}/mini-${UI}${BRANCH}.iso"
 }
 
 preserve_artifacts() {
 	#
 	# Check is we're in a pu/* branch, and if so save the udebs
 	#
-	if PU_BRANCH_DIR=$(replace_origin_pu "/srv/udebs/" $GIT_BRANCH) ; then
-		mkdir -p $PU_BRANCH_DIR
-		cp ${RESULT_DIR}/*.udeb $PU_BRANCH_DIR
+	if udeb_dir=$(replace_origin_pu "/srv/udebs/" $GIT_BRANCH) ; then
+		mkdir -p $udeb_dir
+		cp ${RESULT_DIR}/*.udeb $udeb_dir
+		# this is put into env.txt below, so that the variable(s) can be injected into the jenkins environment
+		ENV_TO_INJECT="OUR_BRANCH=$GIT_BRANCH"
 	fi
 
 	#
 	# Alternatively, if we built an images tarball and were triggered by a pu/ branch
 	#
 	IMAGETAR=${RESULT_DIR}/debian-installer-images_*.tar.gz
-	if [ -f $IMAGETAR -a "$PU_GIT_BRANCH" ] ; then
+	if [ -f $IMAGETAR -a "$TRIGGERING_BRANCH" ] ; then
 		[ -d ${ISO_DIR} ] || mkdir ${ISO_DIR}
 
 		echo "untaring the .iso images from $IMAGETAR:"
@@ -70,8 +73,9 @@ preserve_artifacts() {
 		echo "sha256sum of .iso images:"
 		sha256sum installer-*/*/images/netboot/gtk/mini.iso installer-*/*/images/netboot/mini.iso
 		echo "move them into place..."
-		mv -f installer-*/*/images/netboot/gtk/mini.iso $(iso_target gtk)
-		mv -f installer-*/*/images/netboot/mini.iso $(iso_target text)
+		BRANCH=$(replace_origin_pu "-" $TRIGGERING_BRANCH)
+		mv -f installer-*/*/images/netboot/gtk/mini.iso $(iso_target gtk $BRANCH)
+		mv -f installer-*/*/images/netboot/mini.iso $(iso_target text $BRANCH)
 		echo "and see if they are there (listing creation time):"
 		ls -ltrc $ISO_DIR
 
@@ -126,11 +130,11 @@ pdebuild_package() {
 		NUM_CPU=1
 	fi
 	#
-	# if we got a valid PU_GIT_BRANCH passed in as a parameter from the triggering job
+	# if we got a valid TRIGGERING_BRANCH passed in as a parameter from the triggering job
 	# then grab the generated udebs.  FIXME -- we need to work work out a way of cleaning up old branches
 	#
-	if PU_BRANCH_DIR=$(replace_origin_pu "/srv/udebs/" $PU_GIT_BRANCH) ; then
-		cp $PU_BRANCH_DIR/* build/localudebs
+	if udeb_dir=$(replace_origin_pu "/srv/udebs/" $TRIGGERING_BRANCH) ; then
+		cp $udeb_dir/* build/localudebs
 	fi
 	pdebuild --use-pdebuild-internal --debbuildopts "-j$NUM_CPU -b" --buildresult ${RESULT_DIR} -- --http-proxy $http_proxy
 	# cleanup
@@ -152,3 +156,6 @@ else
 	echo do something else ; exit 1
 fi
 clean_workspace
+
+# write out the environment variable(s) for injection into jenkins job
+echo "$ENV_TO_INJECT" > env.txt
diff --git a/bin/jenkins_master_wrapper.sh b/bin/jenkins_master_wrapper.sh
index 2c81b68..7aefb74 100755
--- a/bin/jenkins_master_wrapper.sh
+++ b/bin/jenkins_master_wrapper.sh
@@ -25,7 +25,7 @@ get_node_ssh_port $NODE_NAME
 case $JOB_NAME in
 	rebootstrap_*) 	PARAMS="$JOB_NAME $@"
 			;;
-	lvc_*) 		PARAMS="$JOB_NAME $EXECUTOR_NUMBER PU_GIT_BRANCH=${PU_GIT_BRANCH:-} $@"
+	lvc_*) 		PARAMS="$JOB_NAME $EXECUTOR_NUMBER TRIGGERING_BRANCH=${TRIGGERING_BRANCH:-} $@"
 			export
 			;;
 	*)		PARAMS="$JOB_NAME"
diff --git a/bin/jenkins_node_wrapper.sh b/bin/jenkins_node_wrapper.sh
index e3807c9..86d95bd 100755
--- a/bin/jenkins_node_wrapper.sh
+++ b/bin/jenkins_node_wrapper.sh
@@ -75,7 +75,7 @@ elif [[ "$*" =~ lvc_.* ]] ; then
 	echo debug end
 	export JOB_NAME=$1 ; shift
 	export EXECUTOR_NUMBER=$1 ; shift
-	export PU_GIT_BRANCH=${1#*=} ; shift
+	export TRIGGERING_BRANCH=${1#*=} ; shift
 	export WORKSPACE=~jenkins/jobs/$JOB_NAME/workspace
 	COMMAND="/srv/jenkins/bin/lvc.sh $@"
 	exec $COMMAND; croak "Exec failed";
diff --git a/bin/lvc.sh b/bin/lvc.sh
index fdb88f9..3b26c90 100755
--- a/bin/lvc.sh
+++ b/bin/lvc.sh
@@ -18,9 +18,9 @@ replace_origin_pu() {
     echo "${PREFIX}pu_${BRANCH#origin/pu/}"
 }
 
-# if $URL is set to "use_PU_GIT_BRANCH" then use the contents of $PU_GIT_BRANCH to work out the locally built ISO name
-if [ "use_PU_GIT_BRANCH" = "$URL" ] ; then
-	if PU_ISO="$(replace_origin_pu "/srv/d-i/isos/mini-gtk-" $PU_GIT_BRANCH).iso" ; then
+# if $URL is set to "use_TRIGGERING_BRANCH" then use the contents of $TRIGGERING_BRANCH to work out the locally built ISO name
+if [ "use_TRIGGERING_BRANCH" = "$URL" ] ; then
+	if PU_ISO="$(replace_origin_pu "/srv/d-i/isos/mini-gtk-" $TRIGGERING_BRANCH).iso" ; then
 		[ -f "$PU_ISO" ] || {
 			echo "looks like we're meant to be testing '$PU_ISO', but it's missing"
 			exit 1
@@ -28,7 +28,7 @@ if [ "use_PU_GIT_BRANCH" = "$URL" ] ; then
 		URL=$PU_ISO
 		echo "using locally built ISO image: URL='$URL'"
 	else
-		echo "URL='$URL' but PU_GIT_BRANCH='$PU_GIT_BRANCH' -- aborting"
+		echo "URL='$URL' but TRIGGERING_BRANCH='$TRIGGERING_BRANCH' -- aborting"
 		exit 1
 	fi
 fi
diff --git a/job-cfg/d-i.yaml.py b/job-cfg/d-i.yaml.py
index d6ae55e..b906547 100755
--- a/job-cfg/d-i.yaml.py
+++ b/job-cfg/d-i.yaml.py
@@ -369,12 +369,12 @@ data.extend(
                          'branches': ['{branch}']}}],
         'builders': [{'shell': '/srv/jenkins/bin/d-i_build.sh'},
                      {'trigger-builds': [{'project': 'lvc_debian-miniiso',
-                      'predefined-parameters': 'PU_GIT_BRANCH=$PU_GIT_BRANCH'
+                      'current-parameters': 'true',
                     }]}],
         'project-type': 'freestyle',
         'properties': prop(type='packages', priority=99),
-        'parameters': [{'string': {'name': 'PU_GIT_BRANCH',
-                                    'description': 'git branch that triggered the build that resulted in this subsequent build.'}}],
+        'parameters': [{'string': {'name': 'TRIGGERING_BRANCH',
+                                   'description': 'git branch that triggered the build that resulted in this subsequent build.'}}],
         'logrotate': lr(90),
         'publishers': publ(irc='debian-boot')}}])
 
@@ -388,16 +388,14 @@ data.extend(
         'scm': [{'git': {'url': '{gitrepo}',
                          'branches': ['{branch}']}}],
         'builders': [ {'shell': '/srv/jenkins/bin/d-i_build.sh'},
+                      {'inject': {'properties-file': 'env.txt'}},
                       {'trigger-builds': [{'project': 'd-i_pu-triggered_debian-installer',
-                       'current-parameters': 'true',
-                       'predefined-parameters': 'PU_GIT_BRANCH=$GIT_BRANCH'
+                       'predefined-parameters': 'TRIGGERING_BRANCH=$OUR_BRANCH'
                        },
                       ]}
                     ],
         'project-type': 'freestyle',
         'properties': prop(type='packages', priority=99),
-        'parameters': [{'string': {'name': 'GIT_BRANCH',
-                                    'description': 'git branch to pretend to have triggered a by-hand build.'}}],
         'logrotate': lr(90),
         'publishers': publ(irc='debian-boot')}}])
 
diff --git a/job-cfg/lvc.yaml b/job-cfg/lvc.yaml
index 78916da..1e4b284 100644
--- a/job-cfg/lvc.yaml
+++ b/job-cfg/lvc.yaml
@@ -24,7 +24,7 @@
             - lvc
     parameters:
       - string:
-          name: PU_GIT_BRANCH
+          name: TRIGGERING_BRANCH
           description: The git branch that triggered the build that reulted in this subsequent build
     logrotate:
       daysToKeep: 90
@@ -107,7 +107,7 @@
                     my_time: 'H */8 * * *'
                 - 'debian-miniiso':
                     dist_name: 'Debian-Installer local mini.iso'
-                    my_iso: 'use_PU_GIT_BRANCH'
+                    my_iso: 'use_TRIGGERING_BRANCH'
                 - 'debian-testing-daily-broken': 
                     dist_name: 'Debian-Installer Testing (Daily) -- Broken Scenarios'
                     my_iso: 'http://cdimage.debian.org/cdimage/daily-builds/daily/arch-latest/amd64/iso-cd/debian-testing-amd64-netinst.iso'

-- 
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