Merge lp:~linaro-automation/linaro-ci/one-time-submission-job into lp:linaro-ci

Proposed by Deepti B. Kalakeri
Status: Merged
Merged at revision: 39
Proposed branch: lp:~linaro-automation/linaro-ci/one-time-submission-job
Merge into: lp:linaro-ci
Diff against target: 122 lines (+118/-0)
1 file modified
jenkins_maintainers_kernel_build_inst (+118/-0)
To merge this branch: bzr merge lp:~linaro-automation/linaro-ci/one-time-submission-job
Reviewer Review Type Date Requested Status
Alexander Sack (community) Needs Resubmitting
Review via email: mp+80222@code.launchpad.net

Description of the change

Adding script for one time job submission.

To post a comment you must log in.
Revision history for this message
Alexander Sack (asac) wrote :

1. + if test -z "$git_branch_ref" ; then
 => I think this and all other sanity checks of input parameters should be moved to the top.

2. since we have quite a few variables and input parameters here itmight make sense to use special syntax for input parameters (like all uppercase, or param_... prefix etc.)

3. + git remote rm "$remote_tree_alias_name"
 => I think this cleanup should be moved to a block that gets always executed (even in case of error). there is a signal syntax to catch errors and jump to a cleanup code block in sh we could use.

4. i am not sure if the cleanup code should be going back to master branch; I dont think it is always the right thing; there can be trees that have no master branch etc. iirc jenkins creates its own branch names. check what branch you are on if you enter the script and switch back to that maybe.

5. I feel we duplicate loads of code here that could be reused from the "normal" kenrel CI job; either refactor things now, or add a blueprint about code-reuse-effort-for-jenkins-scripts.

review: Needs Resubmitting
Revision history for this message
Alexander Sack (asac) wrote :

>
> 3. + git remote rm "$remote_tree_alias_name"
> => I think this cleanup should be moved to a block that gets always executed
> (even in case of error). there is a signal syntax to catch errors and jump to
> a cleanup code block in sh we could use.

here background on this: http://steve-parker.org/sh/trap.shtml

we wantt he cleanup code to be run in case of error and if things go smooth.

Revision history for this message
Alexander Sack (asac) wrote :

haven't checked one by one, but all the parameters provided by the kernel job should be submitted to the dashboard too.

Revision history for this message
Deepti B. Kalakeri (deeptik) wrote :

>
> 1. + if test -z "$git_branch_ref" ; then
> => I think this and all other sanity checks of input parameters should be
> moved to the top.
>
> 2. since we have quite a few variables and input parameters here itmight make
> sense to use special syntax for input parameters (like all uppercase, or
> param_... prefix etc.)
>
> 3. + git remote rm "$remote_tree_alias_name"
> => I think this cleanup should be moved to a block that gets always executed
> (even in case of error). there is a signal syntax to catch errors and jump to
> a cleanup code block in sh we could use.
>

Added a cleanup function using the trap command.
> 4. i am not sure if the cleanup code should be going back to master branch; I
> dont think it is always the right thing; there can be trees that have no
> master branch etc. iirc jenkins creates its own branch names. check what
> branch you are on if you enter the script and switch back to that maybe.
>
DONE
> 5. I feel we duplicate loads of code here that could be reused from the
> "normal" kenrel CI job; either refactor things now, or add a blueprint about
> code-reuse-effort-for-jenkins-scripts.

I would prefer a BP on this and would like this to be done in 2011.11.

40. By Deepti B. Kalakeri

Addressing review comments on script for one time job submission

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'jenkins_maintainers_kernel_build_inst'
--- jenkins_maintainers_kernel_build_inst 1970-01-01 00:00:00 +0000
+++ jenkins_maintainers_kernel_build_inst 2011-10-25 13:56:23 +0000
@@ -0,0 +1,118 @@
1#! /bin/sh
2# Example env variables and its values
3# kernel_config='omap2plus_defconfig'
4# export board_type='panda'
5# kernel_flavour='omap4'
6# rootfs_type='nano'
7set -xe
8
9trap cleanup EXIT
10
11cleanup()
12{
13
14if test "$matching_remote_trees" = "$remote_tree_alias_name" ; then
15 # Cleaning up remote tree that was added
16 git remote rm "$remote_tree_alias_name"
17fi
18if test "$matching_remote_branch" = "$remote_branch_name" ; then
19 # Cleaning up remote branch that was added
20 git checkout $GIT_BRANCH
21 git branch -D $remote_branch_name
22fi
23}
24
25if test -z "$GIT_REMOTE_URL" ; then
26 echo "Please specify the GIT_REMOTE_URL"
27 exit 1
28fi
29if test -z "$GIT_REMOTE_REF" ; then
30 echo "Please specify the GIT_REMOTE_REF"
31 exit 1
32fi
33if test -z "$rootfs_type"; then
34 rootfs_type='nano'
35fi
36
37remote_tree_name=`basename $GIT_REMOTE_URL | awk -F '.git' '{print $1}'`
38remote_tree_alias_name="$remote_tree_name-alias"
39remote_branch_name="$remote_tree_name-branch"
40git remote add "$remote_tree_alias_name" $GIT_REMOTE_URL
41git fetch $remote_tree_alias_name
42matching_remote_trees=`git remote -v | grep "$remote_tree_alias_name" | awk '{ print $1}' | uniq`
43git checkout -b $remote_branch_name $GIT_REMOTE_REF
44matching_remote_branch=`git branch | grep "$remote_branch_name" | awk -F ' ' '{ print $2}'`
45
46bundle_stream_name=`echo $JOB_NAME | sed -e 's/_.*//' -e 's/\./_/g'`
47kernel_config_name=`echo ${kernel_config} | sed -e 's/_defconfig//g'`
48kernel_version=`git describe --match='v*' | sed -e 's/^v//'``echo -${kernel_config_name}-linaro-${kernel_flavour} | sed -e 's/_/-/g'`
49
50# Below is the list of values that will be used in the json files
51log_info=$BUILD_URL"consoleText"
52bundle_stream_name_path="/anonymous/ci-$bundle_stream_name/"
53echo > hwpack_info # start with empty
54echo KERNEL_CONFIG=$kernel_config >> hwpack_info
55echo OS_INFO=`cat /etc/lsb-release | grep DISTRIB_DESCRIPTION | cut -d '=' -f 2` >> hwpack_info
56echo LOG=$log_info >> hwpack_info
57echo BUILD_ID=$BUILD_NUMBER >> hwpack_info
58echo GCC_VERSION=`dpkg -s gcc | grep Version | cut -d ' ' -f2` >> hwpack_info
59echo GCC_CROSS_COMPILER=`dpkg -s gcc-arm-linux-gnueabi | grep Version | cut -d ' ' -f2` >> hwpack_info
60echo BOARD_TYPE=$board_type >> hwpack_info
61echo HWPACK_TYPE=$hwpack_type >> hwpack_info
62echo ROOTFS_TYPE=$rootfs_type >> hwpack_info
63echo BUNDLE_STREAM_NAME=$bundle_stream_name_path >> hwpack_info
64echo JOB_URL=http://ci.linaro.org/kernel_hwpack/ >> hwpack_info
65echo KERNEL_VERSION=`git describe --match='v*'` >> hwpack_info
66echo KERNEL_GIT=$git_remote_url >> hwpack_info
67echo KERNEL_COMMIT=`git rev-parse HEAD` >> hwpack_info
68echo COMMIT_TIME=`git show -s --format=%cD HEAD` >> hwpack_info
69echo KERNEL_NAME=$bundle_stream_name >> hwpack_info
70echo SUBMIT_LAVA_JOB=$submit_job >> hwpack_info
71echo KERNEL_BUILD_URL=$BUILD_URL >> hwpack_info
72echo KERNEL_BRANCH=`git branch | grep -e '*' | cut -d '*' -f 2` >> hwpack_info
73echo KERNEL_JOB_NAME=$JOB_NAME >> hwpack_info
74echo GIT_LOG=`git log -n1 --pretty=oneline` >> hwpack_info
75
76rm -f *.deb
77cp scripts/package/builddeb scripts/package/builddeb.orig
78cp builddeb scripts/package/builddeb
79cpu_count=`cat /proc/cpuinfo | grep processor | wc -l`
80if test x$cpu_count = x; then
81 cpu_count=1
82fi
83j_count=`expr $cpu_count '*' 2`
84
85pkg_dir=$kernel_version"_output_dir"
86rm -rf $pkg_dir
87mkdir $pkg_dir
88
89echo "DEBUG: The remote branch: $remote_branch_name will be built now for the commit id $KERNEL_VERSION"
90START=$(date +%s)
91make ARCH=arm clean mrproper
92make ARCH=arm O=$pkg_dir KERNELVERSION="$kernel_version" KERNELRELEASE="$kernel_version" CROSS_COMPILE=arm-linux-gnueabi- $kernel_config
93yes "" | make ARCH=arm O=$pkg_dir KERNELVERSION="$kernel_version" KERNELRELEASE="$kernel_version" CROSS_COMPILE=arm-linux-gnueabi- oldconfig
94
95# Enabling the THUMB2 kernel option as the THUMB kernel does not seem to work
96# well with THUMB2 userspace. This fixes the reboot issue(bug: 860556) we have seen
97# for THUMB Kernel working with THUMB2 userspace.
98
99echo "CONFIG_ARCH_OMAP2=n" >> $WORKSPACE/$pkg_dir/.config
100echo "CONFIG_THUMB2_KERNEL=y" >> $WORKSPACE/$pkg_dir/.config
101yes "" | make ARCH=arm O=$pkg_dir KERNELVERSION="$kernel_version" KERNELRELEASE="$kernel_version" CROSS_COMPILE=arm-linux-gnueabi- oldconfig
102make ARCH=arm O=$pkg_dir KERNELVERSION="$kernel_version" KERNELRELEASE="$kernel_version" CROSS_COMPILE=arm-linux-gnueabi- -j$j_count uImage
103make ARCH=arm O=$pkg_dir KERNELVERSION="$kernel_version" KERNELRELEASE="$kernel_version" CROSS_COMPILE=arm-linux-gnueabi- -j$j_count modules
104make ARCH=arm O=$pkg_dir KERNELVERSION="$kernel_version" KERNELRELEASE="$kernel_version" CROSS_COMPILE=arm-linux-gnueabi- KBUILD_DEBARCH=armel V=1 deb-pkg
105END=$(date +%s)
106EXECUTION_TIME_IN_SEC=$(( $END - $START ))
107
108latest_kernel=`python lci-build-tools/get_latest_slo_hwpack`
109latest_hwpack_name=`basename $latest_kernel`
110wget -c $latest_kernel
111rm -rf linaro-image-tools
112bzr branch lp:linaro-image-tools
113new_hwpack_name=`python linaro-image-tools/linaro-hwpack-replace -t $latest_hwpack_name -p ./linux-image*${kernel_version}*.deb -r linux-image -n $BUILD_NUMBER`
114use_hwpack_name=`basename $new_hwpack_name`
115echo HWPACK_NAME=$use_hwpack_name >> hwpack_info
116echo URL=$JENKINS_HOME/jobs/$JOB_NAME/workspace/$use_hwpack_name >> hwpack_info
117echo EXECUTION_TIME_IN_SEC=$(( $END - $START )) >> hwpack_info
118echo HWPACK_BUILD_DATE=`echo $use_hwpack_name | cut -d '_' -f3` >>hwpack_info

Subscribers

People subscribed via source and target branches