|
| 1 | +#!groovy |
| 2 | + |
| 3 | +void setBuildStatus(String message, String state) { |
| 4 | + step([ |
| 5 | + $class: "GitHubCommitStatusSetter", |
| 6 | + reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/STEllAR-GROUP/octotiger"], |
| 7 | + contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "ci/jenkins/build-status"], |
| 8 | + errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]], |
| 9 | + statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ] |
| 10 | + ]); |
| 11 | +} |
| 12 | + |
| 13 | +pipeline { |
| 14 | + agent any |
| 15 | + |
| 16 | + options { |
| 17 | + buildDiscarder( |
| 18 | + logRotator( |
| 19 | + daysToKeepStr: "21", |
| 20 | + numToKeepStr: "50", |
| 21 | + artifactDaysToKeepStr: "21", |
| 22 | + artifactNumToKeepStr: "50" |
| 23 | + ) |
| 24 | + ) |
| 25 | + } |
| 26 | + environment { |
| 27 | + GITHUB_TOKEN = credentials('GITHUB_TOKEN_OCTOTIGER') |
| 28 | + } |
| 29 | + stages { |
| 30 | + stage('checkout') { |
| 31 | + steps { |
| 32 | + dir('octotiger') { |
| 33 | + checkout scm |
| 34 | + echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL}" |
| 35 | + } |
| 36 | + } |
| 37 | + } |
| 38 | + stage('build') { |
| 39 | + matrix { |
| 40 | + axes { |
| 41 | + axis { |
| 42 | + name 'compiler_config' |
| 43 | + values 'with-CC', 'with-CC-clang' |
| 44 | + } |
| 45 | + axis { |
| 46 | + name 'cuda_config' |
| 47 | + values 'with-cuda', 'without-cuda' |
| 48 | + } |
| 49 | + axis { |
| 50 | + name 'kokkos_config' |
| 51 | + values 'with-kokkos', 'without-kokkos' |
| 52 | + } |
| 53 | + axis { |
| 54 | + name 'build_type' |
| 55 | + values 'Release' |
| 56 | + } |
| 57 | + } |
| 58 | + stages { |
| 59 | + stage('init') { |
| 60 | + steps { |
| 61 | + dir('octotiger') { |
| 62 | + sh ''' |
| 63 | + github_token=$(echo ${GITHUB_TOKEN} | cut -f2 -d':') |
| 64 | + curl --verbose\ |
| 65 | + --request POST \ |
| 66 | + --url "https://api.github.com/repos/STEllAR-GROUP/octotiger/statuses/$GIT_COMMIT" \ |
| 67 | + --header "Content-Type: application/json" \ |
| 68 | + --header "authorization: Bearer ${github_token}" \ |
| 69 | + --data "{ |
| 70 | + \\"state\\": \\"pending\\", |
| 71 | + \\"context\\": \\"jenkins-${compiler_config}-${cuda_config}-${kokkos_config}\\", |
| 72 | + \\"description\\": \\"Jenkins CI Job: ${compiler_config}-${cuda_config}-${kokkos_config}\\", |
| 73 | + \\"target_url\\": \\"https://rostam.cct.lsu.edu/jenkins/job/Octo-Tiger/$BUILD_NUMBER/console\\" |
| 74 | + }" |
| 75 | + ''' |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | + stage('checkout_buildscripts') { |
| 80 | + steps { |
| 81 | + dir('octotiger') { |
| 82 | + sh ''' |
| 83 | + #!/bin/bash -l |
| 84 | + cd .. |
| 85 | + #rm -rf octo-buildscripts/src/octotiger |
| 86 | + #rm -rf "octo-buildscripts-${compiler_config}-${cuda_config}-${kokkos_config}" #remove line for dependency caching |
| 87 | + if [[ -d "octo-buildscripts-${compiler_config}-${cuda_config}-${kokkos_config}" ]] |
| 88 | + then |
| 89 | + cd "octo-buildscripts-${compiler_config}-${cuda_config}-${kokkos_config}" |
| 90 | + git reset --hard # reset griddim modification in case of unclean directory |
| 91 | + git pull |
| 92 | + rm -rf build/octotiger |
| 93 | + rm -rf src/octotiger |
| 94 | + else |
| 95 | + git clone https://github.com/diehlpk/PowerTiger.git "octo-buildscripts-${compiler_config}-${cuda_config}-${kokkos_config}" |
| 96 | + cd "octo-buildscripts-${compiler_config}-${cuda_config}-${kokkos_config}" |
| 97 | + git checkout clang_build |
| 98 | + mkdir src |
| 99 | + fi |
| 100 | +
|
| 101 | + cd .. |
| 102 | + pwd |
| 103 | + cp -r octotiger "octo-buildscripts-${compiler_config}-${cuda_config}-${kokkos_config}/src/octotiger" |
| 104 | + ''' |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + stage('build') { |
| 109 | + steps { |
| 110 | + dir('octotiger') { |
| 111 | + sh ''' |
| 112 | + #!/bin/bash -l |
| 113 | + cd "../octo-buildscripts-${compiler_config}-${cuda_config}-${kokkos_config}" |
| 114 | + src/octotiger/.jenkins/lsu/entry.sh |
| 115 | + ''' |
| 116 | + } |
| 117 | + } |
| 118 | + } |
| 119 | + } |
| 120 | + post { |
| 121 | + success { |
| 122 | + sh ''' |
| 123 | + github_token=$(echo ${GITHUB_TOKEN} | cut -f2 -d':') |
| 124 | + curl --verbose\ |
| 125 | + --request POST \ |
| 126 | + --url "https://api.github.com/repos/STEllAR-GROUP/octotiger/statuses/$GIT_COMMIT" \ |
| 127 | + --header "Content-Type: application/json" \ |
| 128 | + --header "authorization: Bearer ${github_token}" \ |
| 129 | + --data "{ |
| 130 | + \\"state\\": \\"success\\", |
| 131 | + \\"context\\": \\"jenkins-${compiler_config}-${cuda_config}-${kokkos_config}\\", |
| 132 | + \\"description\\": \\"Jenkins CI Job: ${compiler_config}-${cuda_config}-${kokkos_config}\\", |
| 133 | + \\"target_url\\": \\"https://rostam.cct.lsu.edu/jenkins/job/Octo-Tiger/$BUILD_NUMBER/console\\" |
| 134 | + }" |
| 135 | + ''' |
| 136 | + } |
| 137 | + failure { |
| 138 | + sh ''' |
| 139 | + github_token=$(echo ${GITHUB_TOKEN} | cut -f2 -d':') |
| 140 | + curl --verbose\ |
| 141 | + --request POST \ |
| 142 | + --url "https://api.github.com/repos/STEllAR-GROUP/octotiger/statuses/$GIT_COMMIT" \ |
| 143 | + --header "Content-Type: application/json" \ |
| 144 | + --header "authorization: Bearer ${github_token}" \ |
| 145 | + --data "{ |
| 146 | + \\"state\\": \\"failure\\", |
| 147 | + \\"context\\": \\"jenkins-${compiler_config}-${cuda_config}-${kokkos_config}\\", |
| 148 | + \\"description\\": \\"Jenkins CI Job: ${compiler_config}-${cuda_config}-${kokkos_config}\\", |
| 149 | + \\"target_url\\": \\"https://rostam.cct.lsu.edu/jenkins/job/Octo-Tiger/$BUILD_NUMBER/console\\" |
| 150 | + }" |
| 151 | + ''' |
| 152 | + } |
| 153 | + aborted { |
| 154 | + sh ''' |
| 155 | + github_token=$(echo ${GITHUB_TOKEN} | cut -f2 -d':') |
| 156 | + curl --verbose\ |
| 157 | + --request POST \ |
| 158 | + --url "https://api.github.com/repos/STEllAR-GROUP/octotiger/statuses/$GIT_COMMIT" \ |
| 159 | + --header "Content-Type: application/json" \ |
| 160 | + --header "authorization: Bearer ${github_token}" \ |
| 161 | + --data "{ |
| 162 | + \\"state\\": \\"error\\", |
| 163 | + \\"context\\": \\"jenkins-${compiler_config}-${cuda_config}-${kokkos_config}\\", |
| 164 | + \\"description\\": \\"Jenkins CI Job: ${compiler_config}-${cuda_config}-${kokkos_config}\\", |
| 165 | + \\"target_url\\": \\"https://rostam.cct.lsu.edu/jenkins/job/Octo-Tiger/$BUILD_NUMBER/console\\" |
| 166 | + }" |
| 167 | + ''' |
| 168 | + } |
| 169 | + } |
| 170 | + } |
| 171 | + } |
| 172 | + } |
| 173 | +} |
0 commit comments