| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | #--------------------------------------------------------------# |
| 3 | # Continuous integration script for Jenkins # |
| 4 | #--------------------------------------------------------------# |
| 5 | # |
| 6 | # Default mode : |
| 7 | # This script will exit with error (exit code 1) if any of its steps fails. |
| 8 | # To change this behaviour, choose DO_NOT_STOP_AT_ERROR in Jenkins (see below). |
| 9 | #--------------------------------------------------------------# |
| 10 | set +xv |
| 11 | |
| 12 | echoscip-shell system . . echo. " |
| 13 | ----------------------------------------- |
| 14 | Miscellaneous information |
| 15 | ----------------------------------------- |
| 16 | date : `datescip-shell system . . date.` |
| 17 | hostname : `hostnamescip-shell system . . hostname.` |
| 18 | pwd : `pwdscip-shell system . . pwd.` |
| 19 | |
| 20 | ----------------------------------------- |
| 21 | Jenkins build parameters (user defined) |
| 22 | ----------------------------------------- |
| 23 | BRANCH_TO_BUILD : ${BRANCH_TO_BUILD} |
| 24 | INRIA_FORGE_LOGIN : ${INRIA_FORGE_LOGIN} |
| 25 | DO_NOT_STOP_AT_ERROR : ${DO_NOT_STOP_AT_ERROR} |
| 26 | |
| 27 | ----------------------------------------- |
| 28 | Jenkins build parameters (built in) |
| 29 | ----------------------------------------- |
| 30 | BUILD_NUMBER : ${BUILD_NUMBER} |
| 31 | JENKINS_HOME : ${JENKINS_HOME} |
| 32 | WORKSPACE : ${WORKSPACE} |
| 33 | " |
| 34 | |
| 35 | error_codescip-shell shell discosnp 1:2.6.2-5 error_code(). () { [scip-shell system . . `[`. "$DO_NOT_STOP_AT_ERROR" = "true" ] && { return 0 ; } } |
| 36 | |
| 37 | [scip-shell system . . `[`. "$DO_NOT_STOP_AT_ERROR" != "true" ] && { set -e ; } || { echoscip-shell system . . echo. "(!) DEBUG mode, the script will NOT stop..." ; echoscip-shell system . . echo.; } |
| 38 | set -xv |
| 39 | |
| 40 | # quick look at resources |
| 41 | #----------------------------------------------- |
| 42 | freescip-shell system . . free. -h |
| 43 | #----------------------------------------------- |
| 44 | lstopo |
| 45 | #----------------------------------------------- |
| 46 | dfscip-shell system . . df. -kh |
| 47 | #----------------------------------------------- |
| 48 | |
| 49 | |
| 50 | ################################################################ |
| 51 | # COMPILATION # |
| 52 | ################################################################ |
| 53 | |
| 54 | gccscip-shell system . . gcc. --version |
| 55 | g++ --version |
| 56 | |
| 57 | [scip-shell system . . `[`. `gccscip-shell system . . gcc. -dumpversion` = 4.7 ] && { echoscip-shell system . . echo. "GCC 4.7"; } || { echoscip-shell system . . echo. "GCC version is not 4.7, we exit"; exit 1; } |
| 58 | |
| 59 | JENKINS_TASK=tool-${TOOL_NAME}-build-debian7-64bits-gcc-4.7-gitlab |
| 60 | JENKINS_WORKSPACE=$WORKSPACE/$JENKINS_TASK/ |
| 61 | |
| 62 | GIT_DIR=/scratchdir/builds/workspace/gatb-${TOOL_NAME} |
| 63 | BUILD_DIR=/scratchdir/$JENKINS_TASK/gatb-${TOOL_NAME}/build |
| 64 | |
| 65 | rmscip-shell system . . rm. -rf $BUILD_DIR |
| 66 | mkdirscip-shell system . . mkdir. -p $BUILD_DIR |
| 67 | mkdirscip-shell system . . mkdir. -p $JENKINS_WORKSPACE |
| 68 | |
| 69 | #----------------------------------------------- |
| 70 | # we need gatb-core submodule to be initialized |
| 71 | cd $GIT_DIR |
| 72 | gitscip-shell system . . git. submodule init |
| 73 | gitscip-shell system . . git. submodule update |
| 74 | |
| 75 | #----------------------------------------------- |
| 76 | cd $BUILD_DIR |
| 77 | |
| 78 | #----------------------------------------------- |
| 79 | cmakescip-shell system . . cmake. -Wno-dev -DJENKINS_TAG=${BRANCH_TO_BUILD} $GIT_DIR |
| 80 | |
| 81 | #----------------------------------------------- |
| 82 | makescip-shell system . . make. -j 2 || error_codescip-shell shell discosnp 1:2.6.2-5 error_code(). |
| 83 | |
| 84 | ################################################################ |
| 85 | # TEST # |
| 86 | ################################################################ |
| 87 | # prepare data and scripts |
| 88 | cpscip-shell system . . cp. $GIT_DIR/run_discoSnp++.sh .. |
| 89 | cpscip-shell system . . cp. -R $GIT_DIR/scripts/ .. |
| 90 | cpscip-shell system . . cp. -R $GIT_DIR/test/ .. |
| 91 | # run tests |
| 92 | cd ../test |
| 93 | ./simple_test.sh || error_codescip-shell shell discosnp 1:2.6.2-5 error_code(). |
| 94 | # cleanup disk space |
| 95 | cd .. |
| 96 | rmscip-shell system . . rm. -rf scripts test run_discoSnp++.sh |
| 97 | # go bask to build for packaging step |
| 98 | cd build |
| 99 | |
| 100 | ################################################################ |
| 101 | # PACKAGING # |
| 102 | ################################################################ |
| 103 | |
| 104 | #-- Upload bin bundle as a build artifact |
| 105 | # -> bin bundle *-bin-Linux.tar.gz will be archived as a build artifact |
| 106 | # -> source package is handled by the osx task |
| 107 | |
| 108 | if [scip-shell system . . `[`. $? -eq 0 ] && [scip-shell system . . `[`. "$INRIA_FORGE_LOGIN" != none ] && [scip-shell system . . `[`. "$DO_NOT_STOP_AT_ERROR" != true ]; then |
| 109 | echoscip-shell system . . echo. "Creating a binary archive... " |
| 110 | echoscip-shell system . . echo. "N.B. this is NOT an official binary release" |
| 111 | makescip-shell system . . make. package |
| 112 | |
| 113 | pwdscip-shell system . . pwd. |
| 114 | lsscip-shell system . . ls. -atlhrsF |
| 115 | |
| 116 | #-- Move the generated bin bundle to the workspace (so that it can be uploaded as a Jenkins job artifact) |
| 117 | mvscip-shell system . . mv. *-${BRANCH_TO_BUILD}-bin-Linux.tar.gz $JENKINS_WORKSPACE/ |
| 118 | |
| 119 | fi |
| 120 |