blob: f4e3645c3d394908c826a82f9b2cf63c1eb1f95b [file] [log] [blame]
Zack Williams3403ff42019-08-13 18:30:42 -07001# JJB Macros for ONF jobs
2
pierventrefb03d642020-07-02 23:10:12 +02003# basic string parameters for onf projects
4# differs from lf-infra-parameters as it allows to speficy a different gerrit project
5- parameter:
6 name: onf-infra-parameters
7 parameters:
8 - string:
9 name: PROJECT
10 default: '{project}'
11 - string:
12 name: STREAM
13 default: '{stream}'
14 - string:
15 name: GERRIT_PROJECT
16 default: '{gerrit_project}'
17 - string:
18 name: GERRIT_BRANCH
19 default: '{stream}'
20 - string:
21 name: GERRIT_REFSPEC
22 default: "refs/heads/{stream}"
23 - string:
24 name: sha1
25 default: "origin/{stream}"
26
Carmelo Cascone81631ed2020-08-18 19:33:25 -070027# basic string parameters when using onf-infra-github-pr-trigger-merge
28- parameter:
29 name: onf-infra-github-pr-merge-parameters
30 parameters:
31 - string:
32 name: repoName
33 default: '{repo-name}'
34 description: 'Name of the git repo. Populated by Generic Webhook Trigger'
35
36 - string:
37 name: repoUrl
38 default: '{repo-url}'
39 description: 'URL to the git repo. Populated by Generic Webhook Trigger'
40
41 - string:
42 name: branchName
43 default: '{branch}'
44 description: 'Branch of the project. Populated by Generic Webhook Trigger'
45
46 - string:
47 name: commitHash
48 default: '{sha1}'
49 description: 'SHA string of the merged commit. Populated by Generic Webhook Trigger'
50
51
Zack Williams3403ff42019-08-13 18:30:42 -070052# control how long builds and artifact are retained
53# differs from lf-infra-properties as it retains artifacts
54- property:
55 name: onf-infra-properties
56 properties:
57 - build-discarder:
58 days-to-keep: '{build-days-to-keep}'
59 artifact-num-to-keep: '{artifact-num-to-keep}'
60
Carmelo Cascone81631ed2020-08-18 19:33:25 -070061# Sets permissions for job to be visible to ONFStaff only.
62# Useful when running tools under NDA for which we don't have permission to
63# publish logs or output.
64- property:
65 name: onf-infra-onfstaff-private
66 properties:
67 - raw:
68 xml: |
69 <hudson.security.AuthorizationMatrixProperty>
70 <inheritanceStrategy class="org.jenkinsci.plugins.matrixauth.inheritance.NonInheritingStrategy"/>
71 <permission>com.cloudbees.plugins.credentials.CredentialsProvider.Create:JenkinsPowerusers</permission>
72 <permission>com.cloudbees.plugins.credentials.CredentialsProvider.Delete:JenkinsPowerusers</permission>
73 <permission>com.cloudbees.plugins.credentials.CredentialsProvider.ManageDomains:JenkinsPowerusers</permission>
74 <permission>com.cloudbees.plugins.credentials.CredentialsProvider.Update:JenkinsPowerusers</permission>
75 <permission>com.cloudbees.plugins.credentials.CredentialsProvider.View:JenkinsPowerusers</permission>
76 <permission>hudson.model.Item.Build:JenkinsPowerusers</permission>
77 <permission>hudson.model.Item.Cancel:JenkinsPowerusers</permission>
78 <permission>hudson.model.Item.Configure:JenkinsPowerusers</permission>
79 <permission>hudson.model.Item.Delete:JenkinsPowerusers</permission>
80 <permission>hudson.model.Item.Discover:JenkinsPowerusers</permission>
81 <permission>hudson.model.Item.ExtendedRead:JenkinsPowerusers</permission>
82 <permission>hudson.model.Item.Move:JenkinsPowerusers</permission>
83 <permission>hudson.model.Item.Read:JenkinsPowerusers</permission>
84 <permission>hudson.model.Item.Workspace:JenkinsPowerusers</permission>
85 <permission>hudson.model.Run.Delete:JenkinsPowerusers</permission>
86 <permission>hudson.model.Run.Replay:JenkinsPowerusers</permission>
87 <permission>hudson.model.Run.Update:JenkinsPowerusers</permission>
88 <permission>hudson.model.Item.Discover:ONFStaff</permission>
Carmelo Cascone9a4cbfa2020-08-19 23:11:50 -070089 <permission>hudson.model.Item.Discover:anonymous</permission>
Carmelo Cascone81631ed2020-08-18 19:33:25 -070090 <permission>hudson.model.Item.Read:ONFStaff</permission>
Carmelo Cascone9a4cbfa2020-08-19 23:11:50 -070091 <permission>hudson.model.Item.ViewStatus:anonymous</permission>
Carmelo Cascone81631ed2020-08-18 19:33:25 -070092 </hudson.security.AuthorizationMatrixProperty>
93
Zack Williams3403ff42019-08-13 18:30:42 -070094# trigger on gerrit patchsets and actions
95# docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.gerrit
96# Uses a regex based project match
97- trigger:
98 name: onf-infra-gerrit-trigger-patchset
99 triggers:
100 - gerrit:
101 server-name: '{gerrit-server-name}'
102 dependency-jobs: '{dependency-jobs}'
103 silent-start: true
104 trigger-on:
105 - patchset-created-event:
106 exclude-drafts: true
107 exclude-trivial-rebase: false
108 exclude-no-code-change: false
109 - draft-published-event
110 - comment-added-contains-event:
111 comment-contains-value: '(?i)^.*recheck$'
112 projects:
113 - project-compare-type: REG_EXP
114 project-pattern: '{project-regexp}'
115 branches:
116 - branch-compare-type: REG_EXP
117 branch-pattern: '{branch-regexp}'
118 file-paths:
119 - compare-type: REG_EXP
120 pattern: '{file-include-regexp}'
121
122
123# same as lf-infra-gerrit-scm, but allows checkouts to a subdir of $WORKSPACE
124# with the `basedir` option
125#
126# `basedir` serves the same function as `destination-dir` in the repo scm
127# macros, seems strange that they're named differently.
128- scm:
129 name: onf-infra-gerrit-scm
130 scm:
131 - git:
132 credentials-id: '{jenkins-ssh-credential}'
133 url: '{git-url}'
134 refspec: '{refspec}'
135 branches:
136 - 'refs/heads/{branch}'
137 skip-tag: true
138 wipe-workspace: true
139 submodule:
140 recursive: '{submodule-recursive}'
141 choosing-strategy: '{choosing-strategy}'
142 basedir: '{basedir}'
143
Carmelo Cascone81631ed2020-08-18 19:33:25 -0700144- scm:
145 name: onf-infra-github-ssh-scm
146 scm:
147 - lf-infra-github-scm:
148 url: "git@github.com:{github-organization}/{project}.git"
149 # To checkout PRs and branches
150 refspec: "+refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin/pr/*"
151 # Can be commit hash
152 branch: "{branch}"
153 submodule-recursive:
154 submodule-timeout:
155 submodule-disable:
156 choosing-strategy: default
157 jenkins-ssh-credential: "{ssh-credential}"
Zack Williams3403ff42019-08-13 18:30:42 -0700158
159# trigger for gerrit patch submission
160- trigger:
161 name: onf-infra-gerrit-trigger-merge
162 triggers:
163 - gerrit:
164 server-name: '{gerrit-server-name}'
165 dependency-jobs: '{dependency-jobs}'
166 silent-start: true
167 trigger-on:
168 - change-merged-event
169 projects:
170 - project-compare-type: REG_EXP
171 project-pattern: '{project-regexp}'
172 branches:
173 - branch-compare-type: REG_EXP
174 branch-pattern: '{branch-regexp}'
175 file-paths:
176 - compare-type: REG_EXP
177 pattern: '{file-include-regexp}'
178
179# wrapper to provide SSH key and fill in ~/.ssh/known_hosts file for use with rsync
180- wrapper:
181 name: onf-infra-rsync-wrappers
182 wrappers:
183 - mask-passwords
184 - timeout:
185 type: absolute
186 timeout: '{build-timeout}'
187 timeout-var: 'BUILD_TIMEOUT'
188 fail: true
189 - timestamps
190 - ssh-agent-credentials:
191 users:
192 - '{jenkins-ssh-credential}'
193 - config-file-provider:
194 files:
195 - file-id: known_hosts
196 target: '$HOME/.ssh/known_hosts'
197
pierventrefb03d642020-07-02 23:10:12 +0200198# publisher to clean up the workspace after the build whatever the result
199- publisher:
200 name: onf-infra-wscleanup-publisher
201 publishers:
202 - workspace-cleanup:
203 clean-if:
204 - success: true
205 - unstable: true
206 - failure: true
207 - aborted: true
208 - not-built: true
209 dirmatch: false
210 fail-build: true
211 clean-parent: false
212 disable-deferred-wipeout: false
Carmelo Cascone81631ed2020-08-18 19:33:25 -0700213
214# Trigger on GitHub pull requests
215# docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.github-pull-request
216# Uses the standard 'ok to test', etc. commands per the plugin:
217# https://github.com/jenkinsci/ghprb-plugin
218- trigger:
219 name: onf-infra-github-pr-trigger
220 triggers:
221 - github-pull-request:
222 auth-id: '{github_pr_auth_id}'
223 github-hooks: true # Create github hooks automatically
224 cancel-builds-on-update: true
225 auto-close-on-fail: false
226 only-trigger-phrase: false
227 status-context: '{status_context}' # Name of testing system in PR
228 permit-all: false # don't trigger on every PR
229 org-list: '{obj:github_pr_org_list}'
230 allow-whitelist-orgs-as-admins: true
231
232# Trigger on GitHub PR merge
233# docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.generic-webhook-trigger
234- trigger:
235 name: onf-infra-github-pr-trigger-merge
236 triggers:
237 - generic-webhook-trigger:
238 post-content-params:
239 - type: JSONPath
240 key: action
241 value: $.action
242 - type: JSONPath
243 key: merged
244 value: $.pull_request.merged
245 - type: JSONPath
246 key: repoUrl
247 value: $.pull_request.base.repo.html_url
248 - type: JSONPath
249 key: repoName
250 value: $.pull_request.base.repo.name
251 - type: JSONPath
252 key: branchName
253 value: $.pull_request.base.ref
254 - type: JSONPath
255 key: commitHash
256 value: $.pull_request.merge_commit_sha
257 regex-filter-text: $action,$merged
258 regex-filter-expression: ^(closed,true)$
259 cause: Generic Cause
260 token: '{project}'