|
| 1 | +@Library(value='lammps_testing', changelog=false) |
| 2 | +import org.lammps.ci.Utils |
| 3 | + |
| 4 | +def project_url = 'https://github.com/lammps/lammps.git' |
| 5 | +def set_github_status = false |
| 6 | +def send_slack = true |
| 7 | + |
| 8 | +def lammps_branch = "master" |
| 9 | +def lammps_testing_branch = "master" |
| 10 | + |
| 11 | +node('atlas2') { |
| 12 | + def utils = new Utils() |
| 13 | + |
| 14 | + stage('Checkout') { |
| 15 | + dir('lammps') { |
| 16 | + commit = checkout([$class: 'GitSCM', branches: [[name: "*/${lammps_branch}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 1, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'lammps-jenkins', url: 'https://github.com/lammps/lammps']]]) |
| 17 | + } |
| 18 | + |
| 19 | + dir('lammps-testing') { |
| 20 | + checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: "*/${lammps_testing_branch}"]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'lammps-jenkins', url: 'https://github.com/lammps/lammps-testing']]] |
| 21 | + } |
| 22 | + } |
| 23 | + |
| 24 | + if (set_github_status) { |
| 25 | + utils.setGitHubCommitStatus(project_url, env.JOB_NAME, commit.GIT_COMMIT, 'building...', 'PENDING') |
| 26 | + } |
| 27 | + |
| 28 | + def err = null |
| 29 | + |
| 30 | + try { |
| 31 | + env.LAMMPS_DIR = "${env.WORKSPACE}/lammps" |
| 32 | + env.LAMMPS_TESTING_DIR = "${env.WORKSPACE}/lammps-testing" |
| 33 | + env.LAMMPS_CACHE_DIR = "${env.WORKSPACE}/cache" |
| 34 | + env.LAMMPS_CONTAINER_DIR = "/home/jenkins/containers" |
| 35 | + |
| 36 | + def container = "ubuntu20.04" |
| 37 | + def container_args = "--nv -B /opt/coverity:/opt/coverity" |
| 38 | + |
| 39 | + def build_script = "cmake_coverity.sh" |
| 40 | + |
| 41 | + def launch_container = "singularity exec ${container_args} \$LAMMPS_CONTAINER_DIR/${container}.sif" |
| 42 | + |
| 43 | + timeout(time: 2, unit: 'HOURS') { |
| 44 | + stage('Build') { |
| 45 | + ansiColor('xterm') { |
| 46 | + sh(label: "Run static code analysis in ${container}", |
| 47 | + script: "${launch_container} \$LAMMPS_TESTING_DIR/scripts/static_analysis/${build_script}") |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + def tools = [] |
| 53 | + |
| 54 | + if (build_script.contains("cmake")) { |
| 55 | + tools.add(cmake()) |
| 56 | + } |
| 57 | + |
| 58 | + if (build_script.contains("_icc_")) { |
| 59 | + tools.add(intel()) |
| 60 | + } else if (build_script.contains("_clang_")) { |
| 61 | + tools.add(clang()) |
| 62 | + } else { |
| 63 | + tools.add(gcc()) |
| 64 | + } |
| 65 | + |
| 66 | + recordIssues(tools: tools) |
| 67 | + |
| 68 | + } catch (caughtErr) { |
| 69 | + err = caughtErr |
| 70 | + currentBuild.result = 'FAILURE' |
| 71 | + } finally { |
| 72 | + if (currentBuild.result == 'FAILURE') { |
| 73 | + if (set_github_status) { |
| 74 | + utils.setGitHubCommitStatus(project_url, env.JOB_NAME, commit.GIT_COMMIT, 'build failed!', 'FAILURE') |
| 75 | + } |
| 76 | + if (send_slack) { |
| 77 | + slackSend color: 'danger', message: "Build <${env.BUILD_URL}|#${env.BUILD_NUMBER}> of ${env.JOB_NAME} failed!" |
| 78 | + } |
| 79 | + } else { |
| 80 | + if (set_github_status) { |
| 81 | + utils.setGitHubCommitStatus(project_url, env.JOB_NAME, commit.GIT_COMMIT, 'build successful!', 'SUCCESS') |
| 82 | + } |
| 83 | + if (send_slack) { |
| 84 | + slackSend color: 'good', message: "Build <${env.BUILD_URL}|#${env.BUILD_NUMBER}> of ${env.JOB_NAME} succeeded!" |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + if(err) { |
| 89 | + throw err |
| 90 | + } |
| 91 | + } |
| 92 | +} |
0 commit comments