|
| 1 | +// SPDX-License-Identifier: BSD-3-Clause |
| 2 | +/* Copyright 2019-2021, Intel Corporation */ |
| 3 | + |
| 4 | +/* Jenkinsfile - Scripts to create libpmemobj-cpp and libpmemobj-cpp_matrix jobs - to run with initial jenkins job. */ |
| 5 | + |
| 6 | +/* define common properties of pipelines: */ |
| 7 | +description_param = ''' |
| 8 | + string { |
| 9 | + name('DESCRIPTION') |
| 10 | + defaultValue('') |
| 11 | + trim(true) |
| 12 | + description('Optional description for this execution') |
| 13 | + } |
| 14 | +''' |
| 15 | + |
| 16 | +label_param = ''' |
| 17 | + string { |
| 18 | + name('LABEL') |
| 19 | + defaultValue('fedora') |
| 20 | + trim(true) |
| 21 | + description("Name of the node or group to run job on: rhel8_2, openSUSE15_2, fedora32, ubuntu20_04, ubuntu19.10, debian10, etc.") |
| 22 | + } |
| 23 | +''' |
| 24 | + |
| 25 | +repo_url_param = ''' |
| 26 | + string { |
| 27 | + name('REPO_URL') |
| 28 | + defaultValue('https://github.com/pmem/libpmemobj-cpp.git') |
| 29 | + trim(true) |
| 30 | + description("Git repository address") |
| 31 | + } |
| 32 | +''' |
| 33 | + |
| 34 | +branch_param = ''' |
| 35 | + string { |
| 36 | + name('BRANCH') |
| 37 | + defaultValue('master') |
| 38 | + trim(true) |
| 39 | + description("Repository's branch") |
| 40 | + } |
| 41 | +''' |
| 42 | + |
| 43 | +test_options_param = ''' |
| 44 | + string { |
| 45 | + name('TEST_OPTIONS') |
| 46 | + defaultValue('tests_clang_debug_cpp17_no_valgrind tests_clang_release_cpp11_no_valgrind build_gcc_debug_cpp14 tests_gcc_debug_cpp14_no_valgrind tests_gcc_debug_cpp14_valgrind_memcheck_drd tests_gcc_debug_cpp14_valgrind_other tests_gcc_release_cpp17_no_valgrind ') |
| 47 | + trim(true) |
| 48 | + description("Test builds, as defined in run-build.sh") |
| 49 | + } |
| 50 | +''' |
| 51 | + |
| 52 | +test_device = ''' |
| 53 | + choiceParam('DEVICE_TYPE', ['PMEM', 'DAX', 'NONE'], 'Select tested device type. For PMEM and DAX, capable persistent memory must be present on the server.') |
| 54 | +''' |
| 55 | + |
| 56 | +type_param = ''' |
| 57 | + choiceParam('TEST_TYPE', ['normal'], 'Type of tests') |
| 58 | +''' |
| 59 | + |
| 60 | +check_cpp_style_param = ''' |
| 61 | +choiceParam('CHECK_CPP_STYLE', ['OFF', 'ON'], 'Toggle CHECK_CPP_STYLE') |
| 62 | +''' |
| 63 | + |
| 64 | +tests_long_param = ''' |
| 65 | +choiceParam('TESTS_LONG', ['ON', 'OFF'], 'Toggle TESTS_LONG') |
| 66 | +''' |
| 67 | + |
| 68 | +tbb_param = ''' |
| 69 | +choiceParam('TESTS_TBB', ['ON', 'OFF'], 'Toggle TESTS_TBB') |
| 70 | +''' |
| 71 | + |
| 72 | +pmreorder_param = ''' |
| 73 | +choiceParam('TESTS_PMREORDER', ['ON', 'OFF'], 'Toggle TESTS_PMREORDER') |
| 74 | +''' |
| 75 | + |
| 76 | +timeout_param = ''' |
| 77 | + string { |
| 78 | + name('TEST_TIMEOUT') |
| 79 | + defaultValue('28800') |
| 80 | + trim(true) |
| 81 | + description("Set test timeout") |
| 82 | +} |
| 83 | +''' |
| 84 | + |
| 85 | +coverage_param = ''' |
| 86 | + choiceParam('COVERAGE', ['no', 'yes'], 'Enable code coverage') |
| 87 | +''' |
| 88 | + |
| 89 | +gitlab_connection = ''' |
| 90 | + properties { |
| 91 | + gitLabConnection { |
| 92 | + gitLabConnection('gitlabIT') |
| 93 | + } |
| 94 | + } |
| 95 | +''' |
| 96 | + |
| 97 | +email_options_param = ''' |
| 98 | + string { |
| 99 | + name('EMAIL_RECIPIENTS') |
| 100 | + defaultValue('') |
| 101 | + trim(true) |
| 102 | + description("Recipients of the e-mail sent after execution, separated by the comma.") |
| 103 | + } |
| 104 | + booleanParam('SEND_RESULTS', true, 'Uncheck to disable sending email with report after execution') |
| 105 | +''' |
| 106 | + |
| 107 | +/* Branch with Jenkins libraries to pull: */ |
| 108 | +dev_utils_kit_branch_source = 'master' |
| 109 | +dev_utils_kit_files = 'dev-utils-kit/jenkins' |
| 110 | +libpmemobj_cpp_branch = 'master' |
| 111 | + |
| 112 | +/* Loads pipeline scripts from repository */ |
| 113 | +def remote_definition(current_job_script_path) { |
| 114 | + return """ |
| 115 | + definition { |
| 116 | + cpsScm { |
| 117 | + scm { |
| 118 | + git { |
| 119 | + remote { |
| 120 | + url('https://github.com/pmem/libpmemobj-cpp') |
| 121 | + branch('${libpmemobj_cpp_branch}') |
| 122 | + scriptPath('${current_job_script_path}') |
| 123 | + } |
| 124 | + } |
| 125 | + } |
| 126 | + } |
| 127 | + } |
| 128 | + """ |
| 129 | +} |
| 130 | + |
| 131 | +environmental_variables = """ |
| 132 | + environmentVariables { |
| 133 | + envs( |
| 134 | + api_lib: "${dev_utils_kit_files}/lib/api.groovy", |
| 135 | + lib_path: "${dev_utils_kit_files}/lib/", |
| 136 | + scripts_path: "${dev_utils_kit_files}/scripts/", |
| 137 | + dev_utils_kit_files_repo: "https://github.com/pmem/dev-utils-kit.git", |
| 138 | + dev_utils_kit_branch: "${dev_utils_kit_branch_source}", |
| 139 | + info_addr: "https://github.com/pmem/libpmemobj-cpp.git" |
| 140 | + ) |
| 141 | + } |
| 142 | +""" |
| 143 | + |
| 144 | +triggers = ''' |
| 145 | + triggers { |
| 146 | + gitlabPush { |
| 147 | + buildOnMergeRequestEvents(true) |
| 148 | + buildOnPushEvents(true) |
| 149 | + enableCiSkip(false) |
| 150 | + setBuildDescription(false) |
| 151 | + rebuildOpenMergeRequest('never') |
| 152 | + } |
| 153 | + } |
| 154 | +''' |
| 155 | + |
| 156 | +node { |
| 157 | + stage('libpmemobj-cpp_linux'){ |
| 158 | + jobDsl scriptText: """pipelineJob("libpmemobj-cpp_linux") { |
| 159 | + parameters { |
| 160 | + ${test_device} |
| 161 | + ${label_param} |
| 162 | + ${branch_param} |
| 163 | + ${type_param} |
| 164 | + ${test_options_param} |
| 165 | + ${repo_url_param} |
| 166 | + ${description_param} |
| 167 | + ${check_cpp_style_param} |
| 168 | + ${tests_long_param} |
| 169 | + ${tbb_param} |
| 170 | + ${pmreorder_param} |
| 171 | + ${timeout_param} |
| 172 | + ${coverage_param} |
| 173 | + ${email_options_param} |
| 174 | + } |
| 175 | + ${gitlab_connection} |
| 176 | + ${environmental_variables} |
| 177 | + ${triggers} |
| 178 | + ${remote_definition 'utils/jenkins/libpmemobj-cpp.jenkins'} |
| 179 | + }""" |
| 180 | + } |
| 181 | + stage('libpmemobj-cpp_linux_matrix'){ |
| 182 | + jobDsl scriptText: """matrixJob("libpmemobj-cpp_linux_matrix") { |
| 183 | + parameters { |
| 184 | + matrixCombinationsParam('COMBINATIONS', '', 'choose which combinations to run') |
| 185 | + ${branch_param} |
| 186 | + ${coverage_param} |
| 187 | + ${repo_url_param} |
| 188 | + ${test_options_param} |
| 189 | + ${description_param} |
| 190 | + ${email_options_param} |
| 191 | + } |
| 192 | + axes { |
| 193 | + text('DISTRO', 'ubuntu20_10', 'ubuntu21_04', 'fedora34') |
| 194 | + text('TYPE', 'normal', 'building', 'compatibility') |
| 195 | + label('master', 'master') |
| 196 | + } |
| 197 | + steps { |
| 198 | + downstreamParameterized { |
| 199 | + trigger("libpmemobj-cpp_linux") { |
| 200 | + parameters { |
| 201 | + predefinedProp('COV', '\${COVERAGE}') |
| 202 | + predefinedProp('TEST_TYPE', '\${TYPE}') |
| 203 | + predefinedProp('LABEL', '\${DISTRO}') |
| 204 | + predefinedProp('BRANCH', '\${BRANCH}') |
| 205 | + predefinedProp('TEST_OPTIONS', '\${TEST_OPTIONS}') |
| 206 | + predefinedProp('DEVICE_TYPE', '\${DEVICE_TYPE}') |
| 207 | + predefinedProp('REPO_URL', '\${REPO_URL}') |
| 208 | + predefinedProp('EMAIL_RECIPIENTS', '\${EMAIL_RECIPIENTS}') |
| 209 | + predefinedProp('SEND_EMAIL', '\${SEND_RESULTS}') |
| 210 | + predefinedProp('DESCRIPTION', '\${DESCRIPTION} #Triggered by libpmemobj-cpp matrixJob #\${BUILD_NUMBER} -> \${JENKINS_URL}view/all/job/libpmemobj-cpp_linux_matrix/\${BUILD_NUMBER}') |
| 211 | + } |
| 212 | + block { |
| 213 | + buildStepFailure('FAILURE') |
| 214 | + failure('FAILURE') |
| 215 | + unstable('UNSTABLE') |
| 216 | + } |
| 217 | + } |
| 218 | + } |
| 219 | + } |
| 220 | + }""" |
| 221 | + } |
| 222 | +} |
0 commit comments