Loading Jenkinsfile +138 −122 Original line number Diff line number Diff line // vim: ft=groovy def NUM_CORES = 4 def NUM_CORES = 8 def errors = [] def labels = ['Ubuntu'] // labels for Jenkins node types we will build on def nodes = [:] for (lbl in labels) { def label = lbl def envFile = (label == "CentOS") ? "environment_gcc4.yml" : "environment.yml" nodes[label] = { stage(label) { isisNode(label) { def isisEnv = [ "ISISDATA=/isisData/isis_data", "ISISTESTDATA=/isisData/isis_testData", "ISIS3MGRSCRIPTS=/isisData/data/isis3mgr_scripts", "MALLOC_CHECK_=1" ] def cmakeFlags = [ "-DJP2KFLAG=ON", "-DKAKADU_INCLUDE_DIR=/isisData/kakadu", "-Dpybindings=OFF", "-DCMAKE_BUILD_TYPE=RELEASE" ] def stageStatus = "Checking out ISIS on ${label}" // Checkout checkout scm condaEnv("isis3") { // Environment loginShell """ conda config --env --set channel_alias https://conda.prod-asc.chs.usgs.gov conda config --env --set remote_read_timeout_secs 3600 pipeline { agent { docker { image '950438895271.dkr.ecr.us-west-2.amazonaws.com/asc-jenkins' registryCredentialsId 'ecr:us-west-2:Jenkins-Manager-Role' registryUrl 'https://950438895271.dkr.ecr.us-west-2.amazonaws.com' args '--entrypoint= -v /astro_efs:/astro_efs' } } environment { ISISDATA = '/astro_efs/isis_data' ISISTESTDATA = '/astro_efs/isis_testData' MALLOC_CHECK_ = 1 PATH = "${env.WORKSPACE}/install/bin:${env.PATH}" ISISROOT = "${env.WORKSPACE}/build" KAKADU_HEADERS = '/astro_efs/kakadu_7_9' } stages { stage('Environment Setup') { steps { sh ''' . /home/conda/mambaforge3/etc/profile.d/conda.sh > /dev/null echo "ISISROOT: ${ISISROOT}" echo "CURRENT PATH: ${PATH}" conda create -y -n isis conda activate isis > /dev/null conda install -c conda-forge python=3 findutils conda env update -f ${envFile} --prune mkdir build install """ def osFailed = false isisEnv.add("ISISROOT=${pwd()}/build") isisEnv.add("PATH=${pwd()}/install/bin:${env.PATH}") cmakeFlags.add("-DCMAKE_INSTALL_PREFIX=${pwd()}/install") withEnv(isisEnv) { dir(env.ISISROOT) { // Build stageStatus = "Building ISIS on ${label}" try { loginShell """ cmake -GNinja ${cmakeFlags.join(' ')} ../isis ninja -j${NUM_CORES} install """ } catch(e) { // Die right here error stageStatus mamba env update -f environment.yml --prune conda activate isis mamba install -c conda-forge cxx-compiler git git submodule update --init --recursive conda list ''' } // Unit tests stageStatus = "Running unit tests on ${label}" try { loginShell "ctest -R _unit_ -j${NUM_CORES} --output-on-failure" } catch(e) { errors.add(stageStatus) osFailed = true } // App tests stageStatus = "Running app tests on ${label}" try { loginShell "ctest -R _app_ -j${NUM_CORES} --output-on-failure --timeout 10000" } catch(e) { errors.add(stageStatus) osFailed = true stage('Build') { environment { ISIS_INSTALL_DIR = "${env.WORKSPACE}/install" } steps { sh ''' . /home/conda/mambaforge3/etc/profile.d/conda.sh > /dev/null conda activate isis > /dev/null mkdir -p build install cd build cmake -GNinja -DJP2KFLAG=ON \ -DKAKADU_INCLUDE_DIR=${KAKADU_HEADERS} \ -Dpybindings=OFF \ -DCMAKE_BUILD_TYPE=RELEASE \ -DCMAKE_INSTALL_PREFIX=${ISIS_INSTALL_DIR} \ ../isis ninja -j 8 install ''' } try { loginShell "ctest -R _module_ -j${NUM_CORES} --output-on-failure --timeout 10000" } catch(e) { errors.add(stageStatus) osFailed = true } // Gtests stageStatus = "Running gtests on ${label}" try { loginShell "ctest -R '.' -E '(_app_|_unit_|_module_)' -j${NUM_CORES} --output-on-failure --timeout 10000" } catch(e) { errors.add(stageStatus) osFailed = true } // pytests stageStatus = "Running pytests on ${label}" try { loginShell "cd $WORKSPACE/isis/pytests && pytest ." } catch(e) { errors.add(stageStatus) osFailed = true stage('GTests') { environment { PATH = "${env.WORKSPACE}/install/bin:${env.PATH}" } if (osFailed) { error "Failed on ${label}" steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { sh ''' . /home/conda/mambaforge3/etc/profile.d/conda.sh > /dev/null conda activate isis > /dev/null cd build ctest -R '.' -E '(_app_|_unit_|_module_)' -j 8 --output-on-failure --timeout 10000 ''' } } } stage('Unit Tests') { environment { PATH = "${env.WORKSPACE}/install/bin:${env.PATH}" } steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { sh ''' . /home/conda/mambaforge3/etc/profile.d/conda.sh > /dev/null conda activate isis > /dev/null cd build ctest -R _unit_ -j 8 --output-on-failure ''' } } } stage('App Tests') { environment { PATH = "${env.WORKSPACE}/install/bin:${env.PATH}" } steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { sh ''' . /home/conda/mambaforge3/etc/profile.d/conda.sh > /dev/null conda activate isis > /dev/null cd build ctest -R _app_ -j 8 --output-on-failure --timeout 10000 ''' } } } stage('Module Tests') { environment { PATH = "${env.WORKSPACE}/install/bin:${env.PATH}" } steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { sh ''' . /home/conda/mambaforge3/etc/profile.d/conda.sh > /dev/null conda activate isis > /dev/null cd build ctest -R _module_ -j 8 --output-on-failure --timeout 10000 ''' } } // Run the builds in parallel node { try { parallel nodes } catch(e) { // Report result to GitHub currentBuild.result = "FAILURE" def comment = "Failed during:\n" errors.each { comment += "- ${it}\n" } stage('Py Tests') { environment { PATH = "${env.WORKSPACE}/install/bin:${env.PATH}" } steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { sh ''' . /home/conda/mambaforge3/etc/profile.d/conda.sh > /dev/null conda activate isis > /dev/null cd build cd $WORKSPACE/isis/pytests pytest . setGithubStatus(comment) ''' } } } stage('Deploy') { steps { sh ''' echo "This is where deploy would happen." ''' } } } } Loading
Jenkinsfile +138 −122 Original line number Diff line number Diff line // vim: ft=groovy def NUM_CORES = 4 def NUM_CORES = 8 def errors = [] def labels = ['Ubuntu'] // labels for Jenkins node types we will build on def nodes = [:] for (lbl in labels) { def label = lbl def envFile = (label == "CentOS") ? "environment_gcc4.yml" : "environment.yml" nodes[label] = { stage(label) { isisNode(label) { def isisEnv = [ "ISISDATA=/isisData/isis_data", "ISISTESTDATA=/isisData/isis_testData", "ISIS3MGRSCRIPTS=/isisData/data/isis3mgr_scripts", "MALLOC_CHECK_=1" ] def cmakeFlags = [ "-DJP2KFLAG=ON", "-DKAKADU_INCLUDE_DIR=/isisData/kakadu", "-Dpybindings=OFF", "-DCMAKE_BUILD_TYPE=RELEASE" ] def stageStatus = "Checking out ISIS on ${label}" // Checkout checkout scm condaEnv("isis3") { // Environment loginShell """ conda config --env --set channel_alias https://conda.prod-asc.chs.usgs.gov conda config --env --set remote_read_timeout_secs 3600 pipeline { agent { docker { image '950438895271.dkr.ecr.us-west-2.amazonaws.com/asc-jenkins' registryCredentialsId 'ecr:us-west-2:Jenkins-Manager-Role' registryUrl 'https://950438895271.dkr.ecr.us-west-2.amazonaws.com' args '--entrypoint= -v /astro_efs:/astro_efs' } } environment { ISISDATA = '/astro_efs/isis_data' ISISTESTDATA = '/astro_efs/isis_testData' MALLOC_CHECK_ = 1 PATH = "${env.WORKSPACE}/install/bin:${env.PATH}" ISISROOT = "${env.WORKSPACE}/build" KAKADU_HEADERS = '/astro_efs/kakadu_7_9' } stages { stage('Environment Setup') { steps { sh ''' . /home/conda/mambaforge3/etc/profile.d/conda.sh > /dev/null echo "ISISROOT: ${ISISROOT}" echo "CURRENT PATH: ${PATH}" conda create -y -n isis conda activate isis > /dev/null conda install -c conda-forge python=3 findutils conda env update -f ${envFile} --prune mkdir build install """ def osFailed = false isisEnv.add("ISISROOT=${pwd()}/build") isisEnv.add("PATH=${pwd()}/install/bin:${env.PATH}") cmakeFlags.add("-DCMAKE_INSTALL_PREFIX=${pwd()}/install") withEnv(isisEnv) { dir(env.ISISROOT) { // Build stageStatus = "Building ISIS on ${label}" try { loginShell """ cmake -GNinja ${cmakeFlags.join(' ')} ../isis ninja -j${NUM_CORES} install """ } catch(e) { // Die right here error stageStatus mamba env update -f environment.yml --prune conda activate isis mamba install -c conda-forge cxx-compiler git git submodule update --init --recursive conda list ''' } // Unit tests stageStatus = "Running unit tests on ${label}" try { loginShell "ctest -R _unit_ -j${NUM_CORES} --output-on-failure" } catch(e) { errors.add(stageStatus) osFailed = true } // App tests stageStatus = "Running app tests on ${label}" try { loginShell "ctest -R _app_ -j${NUM_CORES} --output-on-failure --timeout 10000" } catch(e) { errors.add(stageStatus) osFailed = true stage('Build') { environment { ISIS_INSTALL_DIR = "${env.WORKSPACE}/install" } steps { sh ''' . /home/conda/mambaforge3/etc/profile.d/conda.sh > /dev/null conda activate isis > /dev/null mkdir -p build install cd build cmake -GNinja -DJP2KFLAG=ON \ -DKAKADU_INCLUDE_DIR=${KAKADU_HEADERS} \ -Dpybindings=OFF \ -DCMAKE_BUILD_TYPE=RELEASE \ -DCMAKE_INSTALL_PREFIX=${ISIS_INSTALL_DIR} \ ../isis ninja -j 8 install ''' } try { loginShell "ctest -R _module_ -j${NUM_CORES} --output-on-failure --timeout 10000" } catch(e) { errors.add(stageStatus) osFailed = true } // Gtests stageStatus = "Running gtests on ${label}" try { loginShell "ctest -R '.' -E '(_app_|_unit_|_module_)' -j${NUM_CORES} --output-on-failure --timeout 10000" } catch(e) { errors.add(stageStatus) osFailed = true } // pytests stageStatus = "Running pytests on ${label}" try { loginShell "cd $WORKSPACE/isis/pytests && pytest ." } catch(e) { errors.add(stageStatus) osFailed = true stage('GTests') { environment { PATH = "${env.WORKSPACE}/install/bin:${env.PATH}" } if (osFailed) { error "Failed on ${label}" steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { sh ''' . /home/conda/mambaforge3/etc/profile.d/conda.sh > /dev/null conda activate isis > /dev/null cd build ctest -R '.' -E '(_app_|_unit_|_module_)' -j 8 --output-on-failure --timeout 10000 ''' } } } stage('Unit Tests') { environment { PATH = "${env.WORKSPACE}/install/bin:${env.PATH}" } steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { sh ''' . /home/conda/mambaforge3/etc/profile.d/conda.sh > /dev/null conda activate isis > /dev/null cd build ctest -R _unit_ -j 8 --output-on-failure ''' } } } stage('App Tests') { environment { PATH = "${env.WORKSPACE}/install/bin:${env.PATH}" } steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { sh ''' . /home/conda/mambaforge3/etc/profile.d/conda.sh > /dev/null conda activate isis > /dev/null cd build ctest -R _app_ -j 8 --output-on-failure --timeout 10000 ''' } } } stage('Module Tests') { environment { PATH = "${env.WORKSPACE}/install/bin:${env.PATH}" } steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { sh ''' . /home/conda/mambaforge3/etc/profile.d/conda.sh > /dev/null conda activate isis > /dev/null cd build ctest -R _module_ -j 8 --output-on-failure --timeout 10000 ''' } } // Run the builds in parallel node { try { parallel nodes } catch(e) { // Report result to GitHub currentBuild.result = "FAILURE" def comment = "Failed during:\n" errors.each { comment += "- ${it}\n" } stage('Py Tests') { environment { PATH = "${env.WORKSPACE}/install/bin:${env.PATH}" } steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { sh ''' . /home/conda/mambaforge3/etc/profile.d/conda.sh > /dev/null conda activate isis > /dev/null cd build cd $WORKSPACE/isis/pytests pytest . setGithubStatus(comment) ''' } } } stage('Deploy') { steps { sh ''' echo "This is where deploy would happen." ''' } } } }