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 | |
| 164 | # Sets permissions for job to be visible to AetherAccess only |
| 165 | # (for Aether member-only repos). |
| 166 | - property: |
| 167 | name: cord-infra-aether-private |
| 168 | properties: |
| 169 | - raw: |
| 170 | xml: | |
| 171 | <hudson.security.AuthorizationMatrixProperty> |
| 172 | <inheritanceStrategy class="org.jenkinsci.plugins.matrixauth.inheritance.NonInheritingStrategy"/> |
| 173 | <permission>com.cloudbees.plugins.credentials.CredentialsProvider.Create:JenkinsPowerusers</permission> |
| 174 | <permission>com.cloudbees.plugins.credentials.CredentialsProvider.Delete:JenkinsPowerusers</permission> |
| 175 | <permission>com.cloudbees.plugins.credentials.CredentialsProvider.ManageDomains:JenkinsPowerusers</permission> |
| 176 | <permission>com.cloudbees.plugins.credentials.CredentialsProvider.Update:JenkinsPowerusers</permission> |
| 177 | <permission>com.cloudbees.plugins.credentials.CredentialsProvider.View:JenkinsPowerusers</permission> |
| 178 | <permission>hudson.model.Item.Build:JenkinsPowerusers</permission> |
| 179 | <permission>hudson.model.Item.Cancel:JenkinsPowerusers</permission> |
| 180 | <permission>hudson.model.Item.Configure:JenkinsPowerusers</permission> |
| 181 | <permission>hudson.model.Item.Delete:JenkinsPowerusers</permission> |
| 182 | <permission>hudson.model.Item.Discover:JenkinsPowerusers</permission> |
| 183 | <permission>hudson.model.Item.ExtendedRead:JenkinsPowerusers</permission> |
| 184 | <permission>hudson.model.Item.Move:JenkinsPowerusers</permission> |
| 185 | <permission>hudson.model.Item.Read:JenkinsPowerusers</permission> |
| 186 | <permission>hudson.model.Item.Workspace:JenkinsPowerusers</permission> |
| 187 | <permission>hudson.model.Run.Delete:JenkinsPowerusers</permission> |
| 188 | <permission>hudson.model.Run.Replay:JenkinsPowerusers</permission> |
| 189 | <permission>hudson.model.Run.Update:JenkinsPowerusers</permission> |
| 190 | <permission>hudson.model.Item.Discover:AetherAccess</permission> |
| 191 | <permission>hudson.model.Item.Discover:anonymous</permission> |
Carmelo Cascone | 9eb2402 | 2021-01-11 14:11:16 -0800 | [diff] [blame] | 192 | <permission>hudson.model.Item.Discover:ONFStaff</permission> |
Carmelo Cascone | baceafe | 2021-01-10 19:28:49 -0800 | [diff] [blame] | 193 | <permission>hudson.model.Item.Read:AetherAccess</permission> |
Carmelo Cascone | 9eb2402 | 2021-01-11 14:11:16 -0800 | [diff] [blame] | 194 | <permission>hudson.model.Item.Read:ONFStaff</permission> |
Carmelo Cascone | baceafe | 2021-01-10 19:28:49 -0800 | [diff] [blame] | 195 | <permission>hudson.model.Item.ViewStatus:anonymous</permission> |
| 196 | </hudson.security.AuthorizationMatrixProperty> |
Zack Williams | be54231 | 2022-06-23 21:51:32 -0700 | [diff] [blame] | 197 | |
| 198 | ################## NEW and CONVERGED MACROS ################### |
| 199 | # Name matches macro in ONOS/Aether JJB, for future unification |
| 200 | |
| 201 | # control how long builds and artifact are retained |
| 202 | # differs from lf-infra-properties as it retains artifacts |
| 203 | - property: |
| 204 | name: onf-infra-properties |
| 205 | properties: |
| 206 | - build-discarder: |
| 207 | days-to-keep: '{build-days-to-keep}' |
| 208 | artifact-num-to-keep: '{artifact-num-to-keep}' |
| 209 | |
| 210 | # wrapper to provide SSH key and fill in ~/.ssh/known_hosts file for use with rsync |
| 211 | - wrapper: |
| 212 | name: onf-infra-rsync-wrappers |
| 213 | wrappers: |
| 214 | - mask-passwords |
| 215 | - timeout: |
| 216 | type: absolute |
| 217 | timeout: '{build-timeout}' |
| 218 | timeout-var: 'BUILD_TIMEOUT' |
| 219 | fail: true |
| 220 | - timestamps |
| 221 | - ssh-agent-credentials: |
| 222 | users: '{obj:ssh_credential_list}' |
| 223 | - config-file-provider: |
| 224 | files: |
| 225 | - file-id: known_hosts |
| 226 | target: '$HOME/.ssh/known_hosts' |
| 227 | |
| 228 | # trigger on gerrit patchsets and actions |
| 229 | # docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.gerrit |
| 230 | # Uses a regex based project match |
| 231 | - trigger: |
| 232 | name: onf-infra-gerrit-trigger-patchset |
| 233 | triggers: |
| 234 | - gerrit: |
| 235 | server-name: '{gerrit-server-name}' |
| 236 | dependency-jobs: '{dependency-jobs}' |
| 237 | silent-start: true |
| 238 | trigger-on: |
| 239 | - patchset-created-event: |
| 240 | exclude-drafts: true |
| 241 | exclude-trivial-rebase: false |
| 242 | exclude-no-code-change: false |
| 243 | - draft-published-event |
| 244 | - comment-added-contains-event: |
| 245 | comment-contains-value: '(?i)^.*recheck$' |
| 246 | projects: |
| 247 | - project-compare-type: REG_EXP |
| 248 | project-pattern: '{project-regexp}' |
| 249 | branches: |
| 250 | - branch-compare-type: REG_EXP |
| 251 | branch-pattern: '{branch-regexp}' |
| 252 | file-paths: |
| 253 | - compare-type: REG_EXP |
| 254 | pattern: '{file-include-regexp}' |
| 255 | |
| 256 | # trigger for gerrit patch submission |
| 257 | - trigger: |
| 258 | name: onf-infra-gerrit-trigger-merge |
| 259 | triggers: |
| 260 | - gerrit: |
| 261 | server-name: '{gerrit-server-name}' |
| 262 | dependency-jobs: '{dependency-jobs}' |
| 263 | silent-start: true |
| 264 | trigger-on: |
| 265 | - change-merged-event |
| 266 | projects: |
| 267 | - project-compare-type: REG_EXP |
| 268 | project-pattern: '{project-regexp}' |
| 269 | branches: |
| 270 | - branch-compare-type: REG_EXP |
| 271 | branch-pattern: '{branch-regexp}' |
| 272 | file-paths: |
| 273 | - compare-type: REG_EXP |
| 274 | pattern: '{file-include-regexp}' |
| 275 | |
| 276 | # same as lf-infra-*-scm, but allows checkouts to a subdir of $WORKSPACE |
| 277 | # with the `basedir` option |
| 278 | # |
| 279 | # `basedir` is used as `destination-dir` for the repo scm macros for |
| 280 | # consistency |
| 281 | |
| 282 | - scm: |
| 283 | name: onf-infra-gerrit-scm |
| 284 | scm: |
| 285 | - git: |
| 286 | credentials-id: '{jenkins-ssh-credential}' |
| 287 | url: '{git-url}' |
| 288 | refspec: '{refspec}' |
| 289 | branches: |
| 290 | - 'refs/heads/{branch}' |
| 291 | wipe-workspace: true |
| 292 | submodule: |
| 293 | disable: '{submodule-disable}' |
| 294 | recursive: '{submodule-recursive}' |
| 295 | timeout: '{submodule-timeout}' |
| 296 | choosing-strategy: '{choosing-strategy}' |
| 297 | basedir: '{basedir}' |
| 298 | |
| 299 | - scm: |
| 300 | name: onf-infra-gerrit-repo-scm |
| 301 | scm: |
| 302 | - repo: |
| 303 | manifest-url: '{manifest-url}' |
| 304 | manifest-branch: '{branch}' |
| 305 | destination-dir: '{basedir}' |
| 306 | jobs: 4 |
| 307 | reset-first: true |
| 308 | depth: 1 |
| 309 | |
| 310 | # download a specific patchset after checking out entire source tree with repo |
| 311 | # docs: https://docs.openstack.org/infra/jenkins-job-builder/builders.html#builders.inject |
| 312 | - builder: |
| 313 | name: onf-infra-gerrit-repo-patch |
| 314 | builders: |
| 315 | - inject: |
| 316 | properties-content: | |
| 317 | BASEDIR={basedir} |
| 318 | GERRIT_PROJECT={project} |
| 319 | GERRIT_CHANGE_NUMBER={change-number} |
| 320 | GERRIT_PATCHSET_NUMBER={patchset-number} |
| 321 | - shell: !include-raw-escape: shell/repo-patch.sh |
| 322 | |
| 323 | # publisher to clean up the workspace after the build whatever the result |
| 324 | - publisher: |
| 325 | name: onf-infra-wscleanup-publisher |
| 326 | publishers: |
| 327 | - workspace-cleanup: |
| 328 | clean-if: |
| 329 | - success: true |
| 330 | - unstable: true |
| 331 | - failure: true |
| 332 | - aborted: true |
| 333 | - not-built: true |
| 334 | dirmatch: false |
| 335 | fail-build: true |
| 336 | clean-parent: false |
| 337 | disable-deferred-wipeout: false |