SHARE
TWEET

WIP Jenkinsfile for illumos-core 2017-01-15

jimklimov Jan 16th, 2017 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ cat Jenkinsfile
  2. #!groovy
  3. /*
  4.  * This is a Jenkinsfile to automate Jenkins CI builds of uillumos-gate
  5.  * as code updates come into its repo (including posted pull requests)
  6.  *
  7.  * This file and its contents are supplied under the terms of the
  8.  * Common Development and Distribution License ("CDDL"). You may
  9.  * only use this file in accordance with the terms of the CDDL.
  10.  *
  11.  * A full copy of the text of the CDDL should have accompanied this
  12.  * source. A copy of the CDDL is also available via the Internet at
  13.  * http://www.illumos.org/license/CDDL.
  14.  *
  15.  * Copyright 2016 Jim Klimov
  16.  *
  17.  */
  18.  
  19. pipeline {
  20.     agent {
  21.         label "illumos-gate-builder"
  22.     }
  23.  
  24.     /*
  25.      * This assumes a zone or server with required illumos-gate building tools
  26.      * For OmniOS you'd need to preinstall 'illumos-tools' per
  27.      *   https://omnios.omniti.com/wiki.php/illumos-tools
  28.      * On OpenIndiana it would be a large set of packages, on OI Hipster just
  29.      * the 'build-essential' per
  30.      *   http://wiki.illumos.org/display/illumos/How+To+Build+illumos
  31.      * On some distros you might need to explicitly add 'gcc-4.4.4-il' and/or
  32.      * legacy "closed binaries" as tarballs or distro-maintained packages.
  33.      * Also pay attention to exact path of GCC you want (dashes, slashes, etc).
  34.      */
  35.     parameters {
  36.         booleanParam(defaultValue: false, description: 'Removes workspace completely before checkout and build', name: 'action_DistcleanRebuild')
  37.         booleanParam(defaultValue: false, description: 'Wipes workspace from untracked files before checkout and build', name: 'action_GitcleanRebuild')
  38.         booleanParam(defaultValue: true,  description: 'Run Git to checkout or update the project sources', name: 'action_DoSCM')
  39.         booleanParam(defaultValue: false, description: 'Recreate "illumos.sh" with settings for the next build run', name: 'action_PrepIllumos')
  40.         booleanParam(defaultValue: true,  description: 'Recreate "illumos.sh" with settings from vendor-buildtools.git repo (used verbatim, no further customizations)', name: 'action_PrepIllumosDistroVendor')
  41.         string(defaultValue: 'git@bitbucket.org:vendordevelopment/vendor-buildtools.git', description: 'Repo URL with DistroVendor build config', name: 'URL_REPO_VENDOR_BUILDTOOLS')
  42.         string(defaultValue: 'data/vendor-core.env', description: 'Relative path to customized "illumos.sh" in the repo with DistroVendor build config', name: 'RELPATH_REPO_VENDOR_BUILDTOOLS__ILLUMOS_SH')
  43.         string(defaultValue: 'vendor-jenkins', description: 'Name of the credential for Git checkout', name: 'CREDENTIAL_REPO_VENDOR_BUILDTOOLS')
  44.         booleanParam(defaultValue: true,  description: 'Run "nightly" script to update or rebuild the project in one big step (depending on other settings)', name: 'action_BuildAll')
  45.         booleanParam(defaultValue: false, description: 'Run "nightly" script to update the project in incremental mode (overrides and disables clobber, lint, check)\nNOTE that an increment that has nothing to do can still take an hour to walk the Makefiles!', name: 'option_BuildIncremental')
  46.         string(defaultValue: '-ntCDAlmprf', description: 'The nightly.sh option flags for the illumos-gate build (gate default is -FnCDAlmprt), including the leading dash.\nNon-DEBUG is the default build type. Recognized flags include:\n*    -A  check for ABI differences in .so files\n*    -C  check for cstyle/hdrchk errors\n*    -D  do a build with DEBUG on\n*    -F  do _not_ do a non-DEBUG build\n*    -G  gate keeper default group of options (-au)\n*    -I  integration engineer default group of options (-ampu)\n*    -M  do not run pmodes (safe file permission checker)\n*    -N  do not run protocmp\n*    -R  default group of options for building a release (-mp)\n*    -U  update proto area in the parent\n*    -f  find unreferenced files (requires -lp, conflicts with incremental)\n*    -i  do an incremental build (no "make clobber")\n*    -l  do "make lint" in \$LINTDIRS (default: "\$SRC y")\n*    -m  send mail to \$MAILTO at end of build\n*    -n  do not do a bringover (aka. pull or clone) from the parent\n*    -p  create packages for PIT/RE\n*    -r  check ELF runtime attributes in the proto area\n*    -t  build and use the tools in \$SRC/tools (default setting)\n*    +t  Use the build tools in \$ONBLD_TOOLS/bin\n*    -u  update proto_list_\$MACH and friends in the parent workspace; when used with -f, also build an unrefmaster.out in the parent\n*    -w  report on differences between previous and current proto areas', name: 'BUILDOPT_NIGHTLY_OPTIONS')
  47.         booleanParam(defaultValue: false, description: 'Run "nightly" script to only produce non-debug binaries of the project', name: 'action_BuildNonDebug')
  48.         string(defaultValue: '-nt', description: 'The alternate nightly.sh option flags for the illumos-gate to produce debug binaries of the project (if selected)', name: 'BUILDOPT_NIGHTLY_OPTIONS_BLDNONDEBUG')
  49.         booleanParam(defaultValue: false, description: 'Run "nightly" script to produce debug binaries of the project', name: 'action_BuildDebug')
  50.         string(defaultValue: '-ntFD', description: 'The alternate nightly.sh option flags for the illumos-gate to produce non-debug binaries of the project (if selected)', name: 'BUILDOPT_NIGHTLY_OPTIONS_BLDDEBUG')
  51.         booleanParam(defaultValue: false, description: 'Run "nightly" script to produce packages of the project (at least one variant should have been built beforehand)', name: 'action_BuildPackages')
  52.         string(defaultValue: '-np', description: 'The alternate nightly.sh option flags for the illumos-gate to produce a local-FS repo with packages of the project (if selected) from previously built binaries', name: 'BUILDOPT_NIGHTLY_OPTIONS_BLDPKG')
  53.         booleanParam(defaultValue: false, description: 'Run "nightly" script to only "make check" the project (and do some related activities)', name: 'action_Check')
  54.         string(defaultValue: '-nCAFir', description: 'The alternate nightly.sh option flags for the illumos-gate post-build checks (if selected)', name: 'BUILDOPT_NIGHTLY_OPTIONS_CHECK')
  55.         booleanParam(defaultValue: false, description: 'Run "nightly" script to only "lint" the project (and do some related activities)', name: 'action_Lint')
  56.         string(defaultValue: '-nl', description: 'The alternate nightly.sh option flags for the illumos-gate post-build linting (if selected)', name: 'BUILDOPT_NIGHTLY_OPTIONS_LINT')
  57.         booleanParam(defaultValue: false, description: 'Enable publishing of local IPS packaging to a remote repository unless earlier steps fail', name: 'action_PublishIPS')
  58.         string(defaultValue: '', description: 'The remote IPS repository URL to which you can publish the updated packages', name: 'URL_IPS_REPO')
  59. /* TODO: Add a sort of build to just update specifed component(s) like a driver module */
  60.         string(defaultValue: '/opt/onbld/closed', description: 'Location where the "closed binaries" are pre-unpacked into', name: 'BUILDOPT_ON_CLOSED_BINS')
  61.         string(defaultValue: '5.16.1', description: 'Installed PERL version to use for the build (5.10, 5.16, 5.16.1, 5.22, etc)', name: 'BUILDOPT_PERL_VERSION')
  62.     }
  63.     environment {
  64.         _ESC_CPP="/usr/lib/cpp" // Workaround for ILLUMOS-6219, must specify Sun Studio cpp
  65.     }
  66.     options {
  67.         buildDiscarder(logRotator(numToKeepStr:'10'))
  68. //        disableConcurrentBuilds()
  69.     }
  70.  
  71.     stages {
  72.         stage("WORKSPACE:DESTROY") {
  73.             when {
  74.                 expression {
  75.                     if (params["action_DistcleanRebuild"] == true) {
  76.                         if (fileExists(file: "${env.WORKSPACE}/.git/config")) {
  77.                             return true;
  78.                         }
  79.                     }
  80.                     return false;
  81.                 }
  82.             }
  83.             steps {
  84.                 echo "Removing '${env.WORKSPACE}' at '${env.NODE_NAME}'"
  85.                 dir("${env.WORKSPACE}") {
  86.                     deleteDir()
  87.                 }
  88.             }
  89.         }
  90.         stage("WORKSPACE:GITWIPE") {
  91.             when {
  92.                 expression {
  93.                     if (params["action_DistcleanRebuild"] == false && params["action_GitcleanRebuild"] == true) {
  94.                         if (fileExists(file: "${env.WORKSPACE}/.git/config")) {
  95.                             return true;
  96.                         }
  97.                     }
  98.                     return false;
  99.                 }
  100.             }
  101.             steps {
  102.                 dir("${env.WORKSPACE}") {
  103.                     echo "Git-cleaning '${env.WORKSPACE}' at '${env.NODE_NAME}'"
  104.                     sh 'git checkout -f'
  105.                     sh 'git clean -d -ff -x'
  106.                 }
  107.             }
  108.             post {
  109.                 failure {
  110.                     echo "ERROR: Git clean failed in '${env.WORKSPACE}' at '${env.NODE_NAME}', removing workspace completely"
  111.                     dir("${env.WORKSPACE}") {
  112.                         deleteDir()
  113.                     }
  114.                 }
  115.             }
  116.         }
  117.         stage("WORKSPACE:CHECKOUT") {
  118.             when {
  119.                 expression {
  120.                     return params["action_DoSCM"] == true
  121.                 }
  122.             }
  123.             steps {
  124.                 sh "mkdir -p '${env.WORKSPACE}'"
  125.                 checkout scm
  126.             }
  127.         }
  128.  
  129.         stage("WORKSPACE:PREPARE-ILLUMOS") {
  130.             when {
  131.                 expression {
  132.                     return params["action_PrepIllumos"] == true
  133.                 }
  134.             }
  135.             steps {
  136. /* TODO: Download closed bins from the internet by default/fallback? */
  137.                 dir("${env.WORKSPACE}") {
  138.                     sh """
  139. sed -e 's,^\\(export NIGHTLY_OPTIONS=\\).*\$,\\1"${params.BUILDOPT_NIGHTLY_OPTIONS}",' \\
  140.     -e 's,^\\(export ON_CLOSED_BINS=\\).*\$,\\1"${params.BUILDOPT_ON_CLOSED_BINS}",' \\
  141. < ./usr/src/tools/env/illumos.sh > ./illumos.sh \\
  142. && chmod +x illumos.sh || exit
  143.  
  144. grep -i omnios /etc/release && \\
  145. sed \\
  146.     -e 's,^\\(export ENABLE_IPP_PRINTING=\\),### \\1,' \\
  147.     -e 's,^\\(export ENABLE_SMB_PRINTING=\\),### \\1,' \\
  148.     -i illumos.sh
  149.  
  150. [ -n "${env._ESC_CPP}" ] && [ -x "${env._ESC_CPP}" ] && \\
  151.     { echo 'export _ESC_CPP="${env._ESC_CPP}"' >> ./illumos.sh || exit ; }
  152.  
  153. sed -e 's,^\\(export CODEMGR_WS=\\).*\$,\\1"${env.WORKSPACE}",' \\
  154.     -i illumos.sh || exit
  155.  
  156. if [ -n "${params.BUILDOPT_PERL_VERSION}" ]; then \\
  157.     [ -d "/usr/perl5/${params.BUILDOPT_PERL_VERSION}/bin" ] || echo "WARNING: Can not find a PERL home at /usr/perl5/${params.BUILDOPT_PERL_VERSION}/bin; will try this version as asked anyways, but the build can fail" >&2
  158.     echo "export PERL_VERSION='${params.BUILDOPT_PERL_VERSION}'" >> ./illumos.sh || exit
  159.     echo "export PERL_PKGVERS='-`echo "${params.BUILDOPT_PERL_VERSION}" | sed s,-,,`'" >> ./illumos.sh || exit
  160. fi
  161. """
  162.                 }
  163.             }
  164.         }
  165.  
  166.         stage("WORKSPACE:PREPARE-VENDOR") {
  167.             when {
  168.                 expression {
  169.                     return params["action_PrepIllumosDistroVendor"] == true
  170.                 }
  171.             }
  172.             steps {
  173. /* TODO: Download closed bins from the internet by default/fallback? */
  174.                 dir("${env.WORKSPACE}") {
  175.                     dir("vendor-buildtools.git") {
  176.                         checkout([$class: 'GitSCM',
  177.                             branches: [[name: '*/master']],
  178.                             doGenerateSubmoduleConfigurations: false,
  179.                             extensions: [[$class: 'CleanCheckout']],
  180.                             submoduleCfg: [],
  181.                             userRemoteConfigs: [[credentialsId: "${params.CREDENTIAL_REPO_VENDOR_BUILDTOOLS}", url: "${params.URL_REPO_VENDOR_BUILDTOOLS}"]]
  182.                         ])
  183.                     }
  184.                     sh """
  185. cat ./vendor-buildtools.git/${params.RELPATH_REPO_VENDOR_BUILDTOOLS__ILLUMOS_SH} \
  186. > ./illumos.sh && chmod +x illumos.sh || exit
  187.  
  188. sed -e 's,^\\(export CODEMGR_WS=\\).*\$,\\1"${env.WORKSPACE}",' \\
  189.     -i illumos.sh || exit
  190. """
  191.                 }
  192.             }
  193.         }
  194.  
  195.         stage("WORKSPACE:BUILD-ALL") {
  196.             environment {
  197.                 str_option_BuildIncremental = params["option_BuildIncremental"] ? "-i" : ""
  198.             }
  199.             when {
  200.                 expression {
  201.                     return params["action_BuildAll"] == true
  202.                 }
  203.             }
  204.             steps {
  205.                 dir("${env.WORKSPACE}") {
  206.                     sh 'if [ ! -x ./nightly.sh ]; then cp -pf ./usr/src/tools/scripts/nightly.sh ./ && chmod +x nightly.sh || exit ; fi'
  207.                     sh '[ -x ./illumos.sh ] && [ -x ./nightly.sh ] && [ -s ./nightly.sh ] && [ -s ./illumos.sh ]'
  208.                     sh """
  209. echo '`date -u`: STARTING ILLUMOS-GATE BUILD-ALL (prepare to wait... a lot... and in silence!)';
  210. egrep '[^#]*export NIGHTLY_OPTIONS=' illumos.sh;
  211. time ./nightly.sh \${str_option_BuildIncremental} illumos.sh; RES=\$?;
  212. [ "\$RES" = 0 ] || echo "BUILD FAILED (code \$RES), see more details in its logs";
  213. exit \$RES;
  214. """
  215.                 }
  216.             }
  217.             post {
  218.                 always {
  219.                     dir("${env.WORKSPACE}") {
  220.                         sh 'echo "BUILD LOG - SHORT:"; cat "`ls -1d log/log.*/ | sort -n | tail -1`/mail_msg"'
  221.                         sh 'echo "ARCHIVE BUILD LOG REPORT:";echo "log/nightly.log" > logs_to_archive.txt && find "`ls -1d log/log.*/ | sort -n | tail -1`" -type f >> logs_to_archive.txt && cat logs_to_archive.txt'
  222.                         script {
  223.                             def fileToArchive = readFile 'logs_to_archive.txt'
  224.                             archiveArtifacts allowEmptyArchive: true, artifacts: fileToArchive
  225. /*
  226.                             archive fileToArchive
  227.                             sh 'rm -f logs_to_archive.txt'
  228. */
  229.                         }
  230.                     }
  231.                 }
  232.             }
  233.         }
  234.  
  235.         stage("WORKSPACE:BUILD_ND") {
  236.             when {
  237.                 expression {
  238.                     return params["action_BuildNonDebug"] == true
  239.                 }
  240.             }
  241.             steps {
  242.                 dir("${env.WORKSPACE}") {
  243.                     sh 'if [ ! -x ./nightly.sh ]; then cp -pf ./usr/src/tools/scripts/nightly.sh ./ && chmod +x nightly.sh || exit ; fi'
  244.                     sh '[ -x ./illumos.sh ] && [ -x ./nightly.sh ] && [ -s ./nightly.sh ] && [ -s ./illumos.sh ]'
  245.                     sh """
  246. tmpscript="./illumos-once-nd.\$\$.sh"
  247. cp ./illumos.sh "\$tmpscript" && chmod +x "\$tmpscript" || exit;
  248. echo 'export NIGHTLY_OPTIONS="${params.BUILDOPT_NIGHTLY_OPTIONS_BLDNONDEBUG}"' >> "\$tmpscript" || exit;
  249. echo '`date -u`: STARTING ILLUMOS-GATE BUILD NON-DEBUG ONLY (prepare to wait... a lot... and in silence!)';
  250. egrep '[^#]*export NIGHTLY_OPTIONS=' "\$tmpscript";
  251. time ./nightly.sh -i "\$tmpscript"; RES=\$?;
  252. [ "\$RES" = 0 ] || echo "BUILD NON-DEBUG FAILED (code \$RES), see more details in its logs";
  253. rm -f "\$tmpscript";
  254. exit \$RES;
  255. """
  256.                 }
  257.             }
  258.             post {
  259.                 always {
  260.                     dir("${env.WORKSPACE}") {
  261.                         sh 'echo "BUILD LOG - SHORT:"; cat "`ls -1d log/log.*/ | sort -n | tail -1`/mail_msg"'
  262.                         sh 'echo "ARCHIVE BUILD LOG REPORT:";echo "log/nightly.log" > logs_to_archive.txt && find "`ls -1d log/log.*/ | sort -n | tail -1`" -type f >> logs_to_archive.txt && cat logs_to_archive.txt'
  263.                         script {
  264.                             def fileToArchive = readFile 'logs_to_archive.txt'
  265.                             archiveArtifacts allowEmptyArchive: true, artifacts: fileToArchive
  266. /*
  267.                             archive fileToArchive
  268.                             sh 'rm -f logs_to_archive.txt'
  269. */
  270.                         }
  271.                     }
  272.                 }
  273.             }
  274.         }
  275.  
  276.         stage("WORKSPACE:BUILD_DEBUG") {
  277.             when {
  278.                 expression {
  279.                     return params["action_BuildDebug"] == true
  280.                 }
  281.             }
  282.             steps {
  283.                 dir("${env.WORKSPACE}") {
  284.                     sh 'if [ ! -x ./nightly.sh ]; then cp -pf ./usr/src/tools/scripts/nightly.sh ./ && chmod +x nightly.sh || exit ; fi'
  285.                     sh '[ -x ./illumos.sh ] && [ -x ./nightly.sh ] && [ -s ./nightly.sh ] && [ -s ./illumos.sh ]'
  286.                     sh """
  287. tmpscript="./illumos-once-debug.\$\$.sh"
  288. cp ./illumos.sh "\$tmpscript" && chmod +x "\$tmpscript" || exit;
  289. echo 'export NIGHTLY_OPTIONS="${params.BUILDOPT_NIGHTLY_OPTIONS_BLDDEBUG}"' >> "\$tmpscript" || exit;
  290. echo '`date -u`: STARTING ILLUMOS-GATE BUILD DEBUG ONLY (prepare to wait... a lot... and in silence!)';
  291. egrep '[^#]*export NIGHTLY_OPTIONS=' "\$tmpscript";
  292. time ./nightly.sh -i "\$tmpscript"; RES=\$?;
  293. [ "\$RES" = 0 ] || echo "BUILD DEBUG FAILED (code \$RES), see more details in its logs";
  294. rm -f "\$tmpscript";
  295. exit \$RES;
  296. """
  297.                 }
  298.             }
  299.             post {
  300.                 always {
  301.                     dir("${env.WORKSPACE}") {
  302.                         sh 'echo "BUILD LOG - SHORT:"; cat "`ls -1d log/log.*/ | sort -n | tail -1`/mail_msg"'
  303.                         sh 'echo "ARCHIVE BUILD LOG REPORT:";echo "log/nightly.log" > logs_to_archive.txt && find "`ls -1d log/log.*/ | sort -n | tail -1`" -type f >> logs_to_archive.txt && cat logs_to_archive.txt'
  304.                         script {
  305.                             def fileToArchive = readFile 'logs_to_archive.txt'
  306.                             archiveArtifacts allowEmptyArchive: true, artifacts: fileToArchive
  307. /*
  308.                             archive fileToArchive
  309.                             sh 'rm -f logs_to_archive.txt'
  310. */
  311.                         }
  312.                     }
  313.                 }
  314.             }
  315.         }
  316.  
  317.         stage("WORKSPACE:BUILD_PKG") {
  318.             when {
  319.                 expression {
  320.                     return params["action_BuildPackages"] == true
  321.                 }
  322.             }
  323.             steps {
  324.                 dir("${env.WORKSPACE}") {
  325.                     sh 'if [ ! -x ./nightly.sh ]; then cp -pf ./usr/src/tools/scripts/nightly.sh ./ && chmod +x nightly.sh || exit ; fi'
  326.                     sh '[ -x ./illumos.sh ] && [ -x ./nightly.sh ] && [ -s ./nightly.sh ] && [ -s ./illumos.sh ]'
  327.                     sh """
  328. tmpscript="./illumos-once-pkg.\$\$.sh"
  329. cp ./illumos.sh "\$tmpscript" && chmod +x "\$tmpscript" || exit;
  330. echo 'export NIGHTLY_OPTIONS="${params.BUILDOPT_NIGHTLY_OPTIONS_BLDPKG}"' >> "\$tmpscript" || exit;
  331. echo '`date -u`: STARTING ILLUMOS-GATE BUILD PACKAGES ONLY (prepare to wait... a lot... and in silence!)';
  332. egrep '[^#]*export NIGHTLY_OPTIONS=' "\$tmpscript";
  333. time ./nightly.sh -i "\$tmpscript"; RES=\$?;
  334. [ "\$RES" = 0 ] || echo "BUILD PACKAGES FAILED (code \$RES), see more details in its logs";
  335. rm -f "\$tmpscript";
  336. exit \$RES;
  337. """
  338.                 }
  339.             }
  340.             post {
  341.                 always {
  342.                     dir("${env.WORKSPACE}") {
  343.                         sh 'echo "BUILD LOG - SHORT:"; cat "`ls -1d log/log.*/ | sort -n | tail -1`/mail_msg"'
  344.                         sh 'echo "ARCHIVE BUILD LOG REPORT:";echo "log/nightly.log" > logs_to_archive.txt && find "`ls -1d log/log.*/ | sort -n | tail -1`" -type f >> logs_to_archive.txt && cat logs_to_archive.txt'
  345.                         script {
  346.                             def fileToArchive = readFile 'logs_to_archive.txt'
  347.                             archiveArtifacts allowEmptyArchive: true, artifacts: fileToArchive
  348. /*
  349.                             archive fileToArchive
  350.                             sh 'rm -f logs_to_archive.txt'
  351. */
  352.                         }
  353.                     }
  354.                 }
  355.             }
  356.         }
  357.  
  358.         stage("WORKSPACE:CHECK") {
  359.             when {
  360.                 expression {
  361.                     return params["action_Check"] == true
  362.                 }
  363.             }
  364.             steps {
  365.                 dir("${env.WORKSPACE}") {
  366.                     echo "Checking the build results in '${env.WORKSPACE}' at '${env.NODE_NAME}'"
  367.                     /* Note: Can this require a specific "make" dialect interpreter? */
  368.                     sh 'if [ ! -x ./nightly.sh ]; then cp -pf ./usr/src/tools/scripts/nightly.sh ./ && chmod +x nightly.sh || exit ; fi'
  369.                     sh '[ -x ./illumos.sh ] && [ -x ./nightly.sh ] && [ -s ./nightly.sh ] && [ -s ./illumos.sh ]'
  370.                     sh """
  371. cp ./illumos.sh ./illumos-once.sh && chmod +x ./illumos-once.sh || exit;
  372. echo 'export NIGHTLY_OPTIONS="${params.BUILDOPT_NIGHTLY_OPTIONS_CHECK}"' >> ./illumos-once.sh || exit;
  373. echo '`date -u`: STARTING ILLUMOS-GATE CHECK (prepare to wait... a lot... and in silence!)';
  374. egrep '[^#]*export NIGHTLY_OPTIONS=' illumos-once.sh;
  375. time ./nightly.sh illumos-once.sh; RES=\$?;
  376. [ "\$RES" = 0 ] || echo "CHECK FAILED (code \$RES), see more details in its logs";
  377. rm -f illumos-once.sh;
  378. exit \$RES;
  379. """
  380.                 }
  381.             }
  382.             post {
  383.                 always {
  384.                     dir("${env.WORKSPACE}") {
  385.                         sh 'echo "BUILD LOG - SHORT:"; cat "`ls -1d log/log.*/ | sort -n | tail -1`/mail_msg"'
  386.                         sh 'echo "ARCHIVE BUILD LOG REPORT:";echo "log/nightly.log" > logs_to_archive.txt && find "`ls -1d log/log.*/ | sort -n | tail -1`" -type f >> logs_to_archive.txt && cat logs_to_archive.txt'
  387.                         script {
  388.                             def fileToArchive = readFile 'logs_to_archive.txt'
  389.                             archiveArtifacts allowEmptyArchive: true, artifacts: fileToArchive
  390. /*
  391.                             archive fileToArchive
  392.                             sh 'rm -f logs_to_archive.txt'
  393. */
  394.                         }
  395.                     }
  396.                 }
  397.             }
  398.         }
  399.  
  400.         stage("WORKSPACE:LINT") {
  401.             when {
  402.                 expression {
  403.                     return params["action_Lint"] == true
  404.                 }
  405.             }
  406.             steps {
  407.                 dir("${env.WORKSPACE}") {
  408.                     sh 'if [ ! -x ./nightly.sh ]; then cp -pf ./usr/src/tools/scripts/nightly.sh ./ && chmod +x nightly.sh || exit ; fi'
  409.                     sh '[ -x ./illumos.sh ] && [ -x ./nightly.sh ] && [ -s ./nightly.sh ] && [ -s ./illumos.sh ]'
  410.                     sh """
  411. tmpscript="./illumos-once-lint.\$\$.sh"
  412. cp ./illumos.sh "\$tmpscript" && chmod +x "\$tmpscript" || exit;
  413. echo 'export NIGHTLY_OPTIONS="${params.BUILDOPT_NIGHTLY_OPTIONS_LINT}"' >> "\$tmpscript" || exit;
  414. echo '`date -u`: STARTING ILLUMOS-GATE LINTING ONLY (prepare to wait... a lot... and in silence!)';
  415. egrep '[^#]*export NIGHTLY_OPTIONS=' "\$tmpscript";
  416. time ./nightly.sh -i "\$tmpscript"; RES=\$?;
  417. [ "\$RES" = 0 ] || echo "LINTING FAILED (code \$RES), see more details in its logs";
  418. rm -f "\$tmpscript";
  419. exit \$RES;
  420. """
  421.                 }
  422.             }
  423.             post {
  424.                 always {
  425.                     dir("${env.WORKSPACE}") {
  426.                         sh 'echo "LINT BUILD LOG - SHORT:"; cat "`ls -1d log/log.*/ | sort -n | tail -1`/mail_msg"'
  427.                         sh 'echo "ARCHIVE LINT LOG REPORT:"; echo "log/nightly.log" > logs_to_archive.txt && find "`ls -1d log/log.*/ | sort -n | tail -1`" -type f >> logs_to_archive.txt && cat logs_to_archive.txt'
  428.                         script {
  429.                             def fileToArchive = readFile 'logs_to_archive.txt'
  430.                             archiveArtifacts allowEmptyArchive: true, artifacts: fileToArchive
  431. /*
  432.                             archive fileToArchive
  433.                             sh 'rm -f logs_to_archive.txt'
  434. */
  435.                         }
  436.                     }
  437.                 }
  438.             }
  439.         }
  440.  
  441.         stage("WORKSPACE:ArchivePackages") {
  442.             steps {
  443.                 dir("${env.WORKSPACE}") {
  444.                     archive includes: '**/packages/*'
  445.                 }
  446.             }
  447.         }
  448.  
  449.         stage("WORKSPACE:PUBLISH_IPS-NON_DEBUG:i386") {
  450.             when {
  451. /* TODO: Additional/alternate conditions, like "env.BRANCH == "master" ? */
  452.                 expression {
  453.                     if (params["URL_IPS_REPO"] == "") {
  454.                         if (env["BRANCH"] == "master") {
  455.                             params["URL_IPS_REPO"] = "/export/ips/pkg";
  456.                         } else {
  457.                             if (env["BRANCH"] == "bugfix") {
  458.                                 params["URL_IPS_REPO"] = "/export/ips/bugfix";
  459.                             } else {
  460.                                 params["URL_IPS_REPO"] = "/export/ips/pr";
  461.                             }
  462.                         }
  463.                     }
  464.                     if (params["action_PublishIPS"] == true) {
  465.                         if (fileExists(file: "${env.WORKSPACE}/packages/i386/nightly-nd/repo.redist/cfg_cache")) {
  466.                             return true;
  467.                         }
  468.                     }
  469.                     return false;
  470.                 }
  471.             }
  472.             steps {
  473.                 dir("${env.WORKSPACE}") {
  474.                     echo "Publishing IPS packages from '${env.WORKSPACE}/packages/i386/nightly-nd/repo.redist/' at '${env.NODE_NAME}' to '${env.URL_IPS_REPO}'"
  475.                     sh 'pkgcopy "${env.WORKSPACE}/packages/i386/nightly-nd/repo.redist/" "${env.URL_IPS_REPO}"'
  476.                 }
  477.             }
  478.         }
  479.         stage("WORKSPACE:PUBLISH_IPS_DEBUG:i386") {
  480.             when {
  481. /* TODO: Additional/alternate conditions, like "env.BRANCH == "master" ? */
  482.                 expression {
  483.                     if (params["URL_IPS_REPO"] == "") {
  484.                         if (env["BRANCH"] == "master") {
  485.                             params["URL_IPS_REPO"] = "/export/ips/pkg";
  486.                         } else {
  487.                             if (env["BRANCH"] == "bugfix") {
  488.                                 params["URL_IPS_REPO"] = "/export/ips/bugfix";
  489.                             } else {
  490.                                 params["URL_IPS_REPO"] = "/export/ips/pr";
  491.                             }
  492.                         }
  493.                     }
  494.                     if (params["action_PublishIPS"] == true) {
  495.                         if (fileExists(file: "${env.WORKSPACE}/packages/i386/nightly/repo.redist/cfg_cache")) {
  496.                             return true;
  497.                         }
  498.                     }
  499.                     return false;
  500.                 }
  501.             }
  502.             steps {
  503.                 dir("${env.WORKSPACE}") {
  504.                     echo "Publishing IPS packages from '${env.WORKSPACE}/packages/i386/nightly/repo.redist/' at '${env.NODE_NAME}' to '${env.URL_IPS_REPO}'"
  505.                     sh 'pkgcopy "${env.WORKSPACE}/packages/i386/nightly/repo.redist/" "${env.URL_IPS_REPO}"'
  506.                 }
  507.             }
  508.         }
  509.     }
  510. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top