Jenkins: Rebuild everything if build number wrong
authorKevin Klues <klueska@cs.berkeley.edu>
Tue, 6 May 2014 22:08:09 +0000 (15:08 -0700)
committerKevin Klues <klueska@cs.berkeley.edu>
Tue, 6 May 2014 22:27:43 +0000 (15:27 -0700)
The build number could mess up if we roll back a change on the branch
and that change happens to be the commit of the last successful build.
Should be rare...

tools/jenkins/launcher.sh

index b1c8954..5a30753 100755 (executable)
@@ -4,7 +4,7 @@
 # It analyzes what parts of the codebase have been modified, compiles everything
 # that is needed, and reports on the results. 
 
-set -e
+#set -e
 
 readonly TMP_DIR=tmp
 readonly DIFF_FILE=$TMP_DIR/changes.txt
@@ -213,6 +213,14 @@ function build_busybox() {
        echo -e "[BUILD_BUSYBOX]: End\n"
 }
 
+function build_all() {
+       build_config
+       build_cross_compiler
+       build_userspace
+       build_busybox
+       build_kernel
+}
+
 # TODO: This won't work for RISCV, it must be changed to whatever is used.
 function run_qemu() {
        echo -e "\n[RUN_AKAROS_IN_QEMU]: Begin"
@@ -252,56 +260,57 @@ function run_qemu() {
 
 if [ "$COMPILE_ALL" == true ]; then
        echo "Building all AKAROS"
-       build_config
-       
-       build_cross_compiler
-       build_userspace
-       build_busybox
-       build_kernel
-
+       build_all
        run_qemu
 
        AFFECTED_COMPONENTS="cross-compiler kernel userspace busybox"
 else
        # Save changed files between last tested commit and current one.
        git diff --stat $(last_stable_build) $GIT_COMMIT > $DIFF_FILE
-
-       # Extract build targets by parsing diff file.
-       AFFECTED_COMPONENTS=`$SCR_GIT_CHANGES $DIFF_FILE $CONF_COMP_COMPONENTS_FILE`
-       # Can contain {cross-compiler, kernel, userspace, busybox}
-
-       if [[ -n $AFFECTED_COMPONENTS ]]; 
-       then
-               echo "Detected changes in "$AFFECTED_COMPONENTS
-               build_config
-
-               if [[ $AFFECTED_COMPONENTS == *cross-compiler* ]]
+       if [ $? -ne 0 ]; then
+               echo "Diff failed, rebuild everything"
+               build_all
+               run_qemu
+
+               AFFECTED_COMPONENTS="cross-compiler kernel userspace busybox"
+       else 
+               # Extract build targets by parsing diff file.
+               AFFECTED_COMPONENTS=`$SCR_GIT_CHANGES $DIFF_FILE $CONF_COMP_COMPONENTS_FILE`
+               # Can contain {cross-compiler, kernel, userspace, busybox}
+
+               if [[ -n $AFFECTED_COMPONENTS ]]; 
                then
-                       build_cross_compiler
-                       build_userspace
-                       build_busybox
-                       build_kernel
-               else 
-                       if [[ $AFFECTED_COMPONENTS == *userspace* ]]
-                       then
-                               build_userspace
-                       fi
+                       echo "Detected changes in "$AFFECTED_COMPONENTS
+                       build_config
 
-                       if [[ $AFFECTED_COMPONENTS == *busybox* ]]
+                       if [[ $AFFECTED_COMPONENTS == *cross-compiler* ]]
                        then
+                               build_cross_compiler
+                               build_userspace
                                build_busybox
-                       fi
-
-                       if [[ $AFFECTED_COMPONENTS == *kernel* ]]
-                       then
                                build_kernel
+                       else 
+                               if [[ $AFFECTED_COMPONENTS == *userspace* ]]
+                               then
+                                       build_userspace
+                               fi
+
+                               if [[ $AFFECTED_COMPONENTS == *busybox* ]]
+                               then
+                                       build_busybox
+                               fi
+
+                               if [[ $AFFECTED_COMPONENTS == *kernel* ]]
+                               then
+                                       build_kernel
+                               fi
                        fi
+               else
+                       echo "Skipping build. No changes detected."
                fi
-       else
-               echo "Skipping build. No changes detected."
-       fi
 
-       run_qemu
+               run_qemu
+       fi
 fi