Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 1 | --- |
| 2 | # CORD JJB macros |
| 3 | |
| 4 | # control how long builds and artifact are retained |
| 5 | - property: |
| 6 | name: cord-infra-properties |
| 7 | properties: |
| 8 | - build-discarder: |
| 9 | days-to-keep: '{build-days-to-keep}' |
| 10 | artifact-num-to-keep: '{artifact-num-to-keep}' |
| 11 | |
| 12 | # checkout entire source tree with repo |
| 13 | # docs: https://docs.openstack.org/infra/jenkins-job-builder/scm.html#scm.repo |
| 14 | - scm: |
| 15 | name: cord-infra-gerrit-repo-scm |
| 16 | scm: |
| 17 | - repo: |
Zack Williams | c27ca2d | 2018-04-11 13:16:45 -0700 | [diff] [blame] | 18 | manifest-url: '{manifest-url}' |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 19 | manifest-branch: '{branch}' |
| 20 | destination-dir: '{destination-dir}' |
| 21 | jobs: 4 |
| 22 | reset-first: true |
| 23 | depth: 1 |
| 24 | |
Zack Williams | 15a31c8 | 2018-08-29 15:10:03 -0700 | [diff] [blame] | 25 | # same as lf-infra-gerrit-scm, but allows checkouts to a subdir of $WORKSPACE |
| 26 | # with the `basedir` option |
| 27 | # |
| 28 | # `basedir` serves the same function as `destination-dir` in the repo scm |
| 29 | # macros, seems strange that they're named differently. |
| 30 | - scm: |
| 31 | name: cord-infra-gerrit-scm |
| 32 | scm: |
| 33 | - git: |
| 34 | credentials-id: '{jenkins-ssh-credential}' |
| 35 | url: '{git-url}' |
| 36 | refspec: '{refspec}' |
| 37 | branches: |
| 38 | - 'refs/heads/{branch}' |
| 39 | skip-tag: true |
| 40 | wipe-workspace: true |
| 41 | submodule: |
| 42 | recursive: '{submodule-recursive}' |
| 43 | choosing-strategy: '{choosing-strategy}' |
| 44 | basedir: '{basedir}' |
| 45 | |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 46 | # trigger on gerrit patchsets and actions |
| 47 | # docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.gerrit |
| 48 | - trigger: |
| 49 | name: cord-infra-gerrit-trigger-patchset |
| 50 | triggers: |
Zack Williams | e64341b | 2018-04-10 22:14:35 -0700 | [diff] [blame] | 51 | - gerrit: |
| 52 | server-name: '{gerrit-server-name}' |
| 53 | dependency-jobs: '{dependency-jobs}' |
| 54 | silent-start: true |
| 55 | trigger-on: |
| 56 | - patchset-created-event: |
| 57 | exclude-drafts: true |
| 58 | exclude-trivial-rebase: false |
| 59 | exclude-no-code-change: true |
| 60 | - draft-published-event |
| 61 | - comment-added-contains-event: |
| 62 | comment-contains-value: '(?i)^.*recheck$' |
| 63 | projects: |
| 64 | - project-compare-type: REG_EXP |
| 65 | project-pattern: '{project-regexp}' |
| 66 | branches: |
| 67 | - branch-compare-type: REG_EXP |
| 68 | branch-pattern: '{branch-regexp}' |
Zack Williams | c27ca2d | 2018-04-11 13:16:45 -0700 | [diff] [blame] | 69 | file-paths: |
| 70 | - compare-type: REG_EXP |
| 71 | pattern: '{file-include-regexp}' |
Zack Williams | 7468c36 | 2018-04-06 09:52:30 -0700 | [diff] [blame] | 72 | |
| 73 | # trigger on gerrit commits/merges |
| 74 | - trigger: |
| 75 | name: cord-infra-gerrit-trigger-merge |
| 76 | triggers: |
Zack Williams | e64341b | 2018-04-10 22:14:35 -0700 | [diff] [blame] | 77 | - gerrit: |
| 78 | server-name: '{gerrit-server-name}' |
| 79 | dependency-jobs: '{dependency-jobs}' |
Zack Williams | 9ac51db | 2018-04-16 16:44:24 -0700 | [diff] [blame] | 80 | silent-start: true |
Zack Williams | e64341b | 2018-04-10 22:14:35 -0700 | [diff] [blame] | 81 | trigger-on: |
| 82 | - change-merged-event |
| 83 | projects: |
| 84 | - project-compare-type: REG_EXP |
| 85 | project-pattern: '{project-regexp}' |
| 86 | branches: |
| 87 | - branch-compare-type: REG_EXP |
| 88 | branch-pattern: '{branch-regexp}' |
Zack Williams | c27ca2d | 2018-04-11 13:16:45 -0700 | [diff] [blame] | 89 | file-paths: |
| 90 | - compare-type: REG_EXP |
| 91 | pattern: '{file-include-regexp}' |
Zack Williams | 5aa37e1 | 2019-02-13 13:28:29 -0700 | [diff] [blame] | 92 | |
Zack Williams | 5d81f81 | 2019-02-27 14:37:09 -0700 | [diff] [blame] | 93 | # Trigger on GitHub pull requests |
| 94 | # docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.github-pull-request |
| 95 | # Uses the standard 'ok to test', etc. commands per the plugin: |
| 96 | # https://github.com/jenkinsci/ghprb-plugin |
Zack Williams | 73c3cf4 | 2019-02-25 23:43:22 -0700 | [diff] [blame] | 97 | - trigger: |
Zack Williams | 5d81f81 | 2019-02-27 14:37:09 -0700 | [diff] [blame] | 98 | name: cord-infra-github-pr-trigger |
Zack Williams | 73c3cf4 | 2019-02-25 23:43:22 -0700 | [diff] [blame] | 99 | triggers: |
| 100 | - github-pull-request: |
Zack Williams | 5d81f81 | 2019-02-27 14:37:09 -0700 | [diff] [blame] | 101 | auth-id: '{github_pr_auth_id}' |
| 102 | github-hooks: true # Create github hooks automatically |
| 103 | cancel-builds-on-update: true |
| 104 | auto-close-on-fail: false |
Zack Williams | 4b5722e | 2019-02-27 15:14:04 -0700 | [diff] [blame] | 105 | only-trigger-phrase: false |
Jeremy Ronquillo | 9adc0a9 | 2020-01-29 10:49:45 -0800 | [diff] [blame] | 106 | status-context: '{status_context}' # Name of testing system in PR |
Zack Williams | 5d81f81 | 2019-02-27 14:37:09 -0700 | [diff] [blame] | 107 | permit-all: false # don't trigger on every PR |
| 108 | org-list: '{obj:github_pr_org_list}' |
| 109 | allow-whitelist-orgs-as-admins: true |
Zack Williams | 73c3cf4 | 2019-02-25 23:43:22 -0700 | [diff] [blame] | 110 | |
You Wang | fd86905 | 2020-03-13 11:23:11 -0700 | [diff] [blame] | 111 | # Trigger on GitHub PR merge |
| 112 | # docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.generic-webhook-trigger |
| 113 | - trigger: |
| 114 | name: cord-infra-github-pr-trigger-merge |
| 115 | triggers: |
| 116 | - generic-webhook-trigger: |
| 117 | post-content-params: |
| 118 | - type: JSONPath |
| 119 | key: action |
| 120 | value: $.action |
| 121 | - type: JSONPath |
| 122 | key: merged |
| 123 | value: $.pull_request.merged |
You Wang | 4487d01 | 2020-03-30 11:09:48 -0700 | [diff] [blame] | 124 | - type: JSONPath |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 125 | key: repoUrl |
| 126 | value: $.pull_request.base.repo.html_url |
| 127 | - type: JSONPath |
| 128 | key: repoName |
| 129 | value: $.pull_request.base.repo.name |
| 130 | - type: JSONPath |
You Wang | 4487d01 | 2020-03-30 11:09:48 -0700 | [diff] [blame] | 131 | key: branchName |
| 132 | value: $.pull_request.base.ref |
| 133 | - type: JSONPath |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 134 | key: commitHash |
| 135 | value: $.pull_request.merge_commit_sha |
You Wang | fd86905 | 2020-03-13 11:23:11 -0700 | [diff] [blame] | 136 | regex-filter-text: $action,$merged |
| 137 | regex-filter-expression: ^(closed,true)$ |
| 138 | cause: Generic Cause |
| 139 | token: '{project}' |
| 140 | |
Zack Williams | 5aa37e1 | 2019-02-13 13:28:29 -0700 | [diff] [blame] | 141 | # wrapper to provide pypi config file |
| 142 | |
| 143 | - wrapper: |
| 144 | name: cord-pypi-wrapper |
| 145 | wrappers: |
| 146 | - mask-passwords |
| 147 | - timeout: |
| 148 | type: absolute |
| 149 | timeout: '{build-timeout}' |
| 150 | timeout-var: 'BUILD_TIMEOUT' |
| 151 | fail: true |
| 152 | - timestamps |
| 153 | - ssh-agent-credentials: |
| 154 | users: |
| 155 | - '{jenkins-ssh-credential}' |
| 156 | - config-file-provider: |
| 157 | files: |
| 158 | - file-id: pypirc |
| 159 | target: '$HOME/.pypirc' |
| 160 | - file-id: pipconf |
| 161 | target: '$HOME/.config/pip/pip.conf' |
Zack Williams | 73c3cf4 | 2019-02-25 23:43:22 -0700 | [diff] [blame] | 162 | |
Carmelo Cascone | baceafe | 2021-01-10 19:28:49 -0800 | [diff] [blame] | 163 | |
Zack Williams | 5f25716 | 2022-07-25 14:22:29 -0700 | [diff] [blame] | 164 | |
Zack Williams | be54231 | 2022-06-23 21:51:32 -0700 | [diff] [blame] | 165 | |
| 166 | ################## NEW and CONVERGED MACROS ################### |
| 167 | # Name matches macro in ONOS/Aether JJB, for future unification |
| 168 | |
| 169 | # control how long builds and artifact are retained |
| 170 | # differs from lf-infra-properties as it retains artifacts |
| 171 | - property: |
| 172 | name: onf-infra-properties |
| 173 | properties: |
| 174 | - build-discarder: |
| 175 | days-to-keep: '{build-days-to-keep}' |
| 176 | artifact-num-to-keep: '{artifact-num-to-keep}' |
| 177 | |
Zack Williams | 5f25716 | 2022-07-25 14:22:29 -0700 | [diff] [blame] | 178 | # Permissions specific to VOLTHA jobs |
| 179 | # JJB supports this, but not the GROUP annotation which causes warnings |
| 180 | # https://jenkins-job-builder.readthedocs.io/en/latest/properties.html?highlight=matrix#properties.authorization |
| 181 | - property: |
| 182 | name: onf-infra-volthadevs-permissions |
| 183 | properties: |
| 184 | - raw: |
| 185 | xml: | |
| 186 | <hudson.security.AuthorizationMatrixProperty> |
| 187 | <inheritanceStrategy class="org.jenkinsci.plugins.matrixauth.inheritance.InheritParentStrategy"/> |
| 188 | <permission>GROUP:hudson.model.Item.Build:VOLTHADevs</permission> |
| 189 | <permission>GROUP:hudson.model.Item.Cancel:VOLTHADevs</permission> |
| 190 | <permission>GROUP:hudson.model.Item.Configure:VOLTHADevs</permission> |
| 191 | <permission>GROUP:hudson.model.Item.Discover:VOLTHADevs</permission> |
| 192 | <permission>GROUP:hudson.model.Item.ExtendedRead:VOLTHADevs</permission> |
| 193 | <permission>GROUP:hudson.model.Item.Read:VOLTHADevs</permission> |
| 194 | <permission>GROUP:hudson.model.Item.Workspace:VOLTHADevs</permission> |
| 195 | <permission>GROUP:hudson.model.Run.Replay:VOLTHADevs</permission> |
| 196 | <permission>GROUP:hudson.model.Run.Update:VOLTHADevs</permission> |
| 197 | </hudson.security.AuthorizationMatrixProperty> |
| 198 | |
Zack Williams | be54231 | 2022-06-23 21:51:32 -0700 | [diff] [blame] | 199 | # wrapper to provide SSH key and fill in ~/.ssh/known_hosts file for use with rsync |
| 200 | - wrapper: |
| 201 | name: onf-infra-rsync-wrappers |
| 202 | wrappers: |
| 203 | - mask-passwords |
| 204 | - timeout: |
| 205 | type: absolute |
| 206 | timeout: '{build-timeout}' |
| 207 | timeout-var: 'BUILD_TIMEOUT' |
| 208 | fail: true |
| 209 | - timestamps |
| 210 | - ssh-agent-credentials: |
| 211 | users: '{obj:ssh_credential_list}' |
| 212 | - config-file-provider: |
| 213 | files: |
| 214 | - file-id: known_hosts |
| 215 | target: '$HOME/.ssh/known_hosts' |
| 216 | |
| 217 | # trigger on gerrit patchsets and actions |
| 218 | # docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.gerrit |
| 219 | # Uses a regex based project match |
| 220 | - trigger: |
| 221 | name: onf-infra-gerrit-trigger-patchset |
| 222 | triggers: |
| 223 | - gerrit: |
| 224 | server-name: '{gerrit-server-name}' |
| 225 | dependency-jobs: '{dependency-jobs}' |
| 226 | silent-start: true |
| 227 | trigger-on: |
| 228 | - patchset-created-event: |
| 229 | exclude-drafts: true |
| 230 | exclude-trivial-rebase: false |
| 231 | exclude-no-code-change: false |
| 232 | - draft-published-event |
| 233 | - comment-added-contains-event: |
| 234 | comment-contains-value: '(?i)^.*recheck$' |
| 235 | projects: |
| 236 | - project-compare-type: REG_EXP |
| 237 | project-pattern: '{project-regexp}' |
| 238 | branches: |
| 239 | - branch-compare-type: REG_EXP |
| 240 | branch-pattern: '{branch-regexp}' |
| 241 | file-paths: |
| 242 | - compare-type: REG_EXP |
| 243 | pattern: '{file-include-regexp}' |
| 244 | |
| 245 | # trigger for gerrit patch submission |
| 246 | - trigger: |
| 247 | name: onf-infra-gerrit-trigger-merge |
| 248 | triggers: |
| 249 | - gerrit: |
| 250 | server-name: '{gerrit-server-name}' |
| 251 | dependency-jobs: '{dependency-jobs}' |
| 252 | silent-start: true |
| 253 | trigger-on: |
| 254 | - change-merged-event |
| 255 | projects: |
| 256 | - project-compare-type: REG_EXP |
| 257 | project-pattern: '{project-regexp}' |
| 258 | branches: |
| 259 | - branch-compare-type: REG_EXP |
| 260 | branch-pattern: '{branch-regexp}' |
| 261 | file-paths: |
| 262 | - compare-type: REG_EXP |
| 263 | pattern: '{file-include-regexp}' |
| 264 | |
| 265 | # same as lf-infra-*-scm, but allows checkouts to a subdir of $WORKSPACE |
| 266 | # with the `basedir` option |
| 267 | # |
| 268 | # `basedir` is used as `destination-dir` for the repo scm macros for |
| 269 | # consistency |
| 270 | |
| 271 | - scm: |
| 272 | name: onf-infra-gerrit-scm |
| 273 | scm: |
| 274 | - git: |
| 275 | credentials-id: '{jenkins-ssh-credential}' |
| 276 | url: '{git-url}' |
| 277 | refspec: '{refspec}' |
| 278 | branches: |
| 279 | - 'refs/heads/{branch}' |
| 280 | wipe-workspace: true |
| 281 | submodule: |
| 282 | disable: '{submodule-disable}' |
| 283 | recursive: '{submodule-recursive}' |
| 284 | timeout: '{submodule-timeout}' |
| 285 | choosing-strategy: '{choosing-strategy}' |
| 286 | basedir: '{basedir}' |
| 287 | |
| 288 | - scm: |
| 289 | name: onf-infra-gerrit-repo-scm |
| 290 | scm: |
| 291 | - repo: |
| 292 | manifest-url: '{manifest-url}' |
| 293 | manifest-branch: '{branch}' |
| 294 | destination-dir: '{basedir}' |
| 295 | jobs: 4 |
| 296 | reset-first: true |
| 297 | depth: 1 |
| 298 | |
| 299 | # download a specific patchset after checking out entire source tree with repo |
| 300 | # docs: https://docs.openstack.org/infra/jenkins-job-builder/builders.html#builders.inject |
| 301 | - builder: |
| 302 | name: onf-infra-gerrit-repo-patch |
| 303 | builders: |
| 304 | - inject: |
| 305 | properties-content: | |
| 306 | BASEDIR={basedir} |
| 307 | GERRIT_PROJECT={project} |
| 308 | GERRIT_CHANGE_NUMBER={change-number} |
| 309 | GERRIT_PATCHSET_NUMBER={patchset-number} |
| 310 | - shell: !include-raw-escape: shell/repo-patch.sh |
| 311 | |
| 312 | # publisher to clean up the workspace after the build whatever the result |
| 313 | - publisher: |
| 314 | name: onf-infra-wscleanup-publisher |
| 315 | publishers: |
| 316 | - workspace-cleanup: |
| 317 | clean-if: |
| 318 | - success: true |
| 319 | - unstable: true |
| 320 | - failure: true |
| 321 | - aborted: true |
| 322 | - not-built: true |
| 323 | dirmatch: false |
| 324 | fail-build: true |
| 325 | clean-parent: false |
| 326 | disable-deferred-wipeout: false |