Update jenkins-cfg-verify to use $GERRIT_REFSPEC
[releng/global-jjb.git] / jjb / lf-whitesource-jobs.yaml
1 ---
2
3 ##########
4 # Macros #
5 ##########
6
7 - builder:
8     name: lf-infra-wss-unified-agent-scan
9     builders:
10       - config-file-provider:
11           files:
12             - file-id: wss-unified-agent.config
13               target: $WORKSPACE/wss-unified-agent.config
14       - shell: !include-raw:
15           - ../shell/whitesource-unified-agent-cli.sh
16
17 ####################
18 # COMMON FUNCTIONS #
19 ####################
20
21 - lf_whitesource_common: &lf_whitesource_common
22     name: lf-whitesource-common
23
24     ######################
25     # Default parameters #
26     ######################
27
28     archive-artifacts: >
29       **/*.log
30
31     #####################
32     # Job Configuration #
33     #####################
34
35     project-type: freestyle
36     node: '{build-node}'
37
38     properties:
39       - lf-infra-properties:
40           build-days-to-keep: '{build-days-to-keep}'
41
42     parameters:
43       - lf-infra-parameters:
44           project: '{project}'
45           branch: '{branch}'
46           stream: '{stream}'
47
48     wrappers:
49       - lf-infra-wrappers:
50           build-timeout: '{build-timeout}'
51           jenkins-ssh-credential: '{jenkins-ssh-credential}'
52       - credentials-binding:
53           - text:
54               credential-id: wss-apiKey
55               variable: wss-apiKey
56
57     publishers:
58       - lf-infra-publish
59
60 ##################################
61 # WHITESOURCE UNIFIED AGENT SCAN #
62 ##################################
63
64 - lf_wss_unified_agent_scan: &lf_wss_unified_agent_scan
65     name: lf-wss-unified-agent-scan
66
67     ######################
68     # Default parameters #
69     ######################
70
71     branch: master
72     build-days-to-keep: 30
73     build-timeout: 60
74     cron: '@daily'
75     disable-job: false
76     git-url: '$GIT_URL/$PROJECT'
77     github-url: 'https://github.com'
78     java-version: openjdk8
79     stream: master
80     submodule-recursive: true
81     submodule-timeout: 10
82     wss-unified-agent-opts: ''
83     wss-unified-agent-version: 19.2.2.2
84
85     gerrit_trigger_file_paths:
86       - compare-type: ANT
87         pattern: '.*'
88
89     # github_included_regions MUST match gerrit_trigger_file_paths
90     github_included_regions:
91       - '.*'
92
93     #####################
94     # Job Configuration #
95     #####################
96
97     disabled: '{disable-job}'
98
99     parameters:
100       - lf-infra-parameters:
101           project: '{project}'
102           branch: '{branch}'
103           stream: '{stream}'
104       - string:
105           name: WSS_PROJECT_NAME
106           default: '{project-name}'
107           description: Project to asociate the WhiteSource report in the dashboard.
108       - string:
109           name: WSS_PRODUCT_NAME
110           default: '{wss-product-name}'
111           description: Product to asociate the WhiteSource report in the dashboard.
112       - string:
113           name: WSS_UNIFIED_AGENT_OPTIONS
114           default: '{wss-unified-agent-opts}'
115           description: Options to pass to the WhiteSource Unified Agent CLI.
116       - string:
117           name: WSS_UNIFIED_AGENT_VERSION
118           default: '{wss-unified-agent-version}'
119           description: WhiteSource Unified Agent version package to download and use.
120
121     builders:
122       - lf-infra-pre-build
123       - lf-update-java-alternatives:
124           java-version: '{java-version}'
125       - lf-infra-wss-unified-agent-scan
126
127 - job-template:
128     name: '{project-name}-whitesource-scan-{stream}'
129     id: gerrit-whitesource-scan
130     <<: *lf_whitesource_common
131     # yamllint disable-line rule:key-duplicates
132     <<: *lf_wss_unified_agent_scan
133
134     ######################
135     # Default parameters #
136     ######################
137
138     gerrit_wss_triggers:
139       - comment-added-contains-event:
140           comment-contains-value: run-whitesource$
141
142     #####################
143     # Job Configuration #
144     #####################
145
146     scm:
147       - lf-infra-gerrit-scm:
148           jenkins-ssh-credential: '{jenkins-ssh-credential}'
149           git-url: '{git-url}'
150           refspec: '$GERRIT_REFSPEC'
151           branch: '$GERRIT_BRANCH'
152           submodule-recursive: '{submodule-recursive}'
153           submodule-timeout: '{submodule-timeout}'
154           choosing-strategy: default
155
156     triggers:
157       # Build weekly on Saturdays
158       - timed: '{obj:cron}'
159       - gerrit:
160           server-name: '{gerrit-server-name}'
161           trigger-on: '{obj:gerrit_wss_triggers}'
162           projects:
163             - project-compare-type: ANT
164               project-pattern: '{project}'
165               branches:
166                 - branch-compare-type: ANT
167                   branch-pattern: '**/{branch}'
168               file-paths: '{obj:gerrit_trigger_file_paths}'
169           skip-vote:
170             successful: true
171             failed: true
172             unstable: true
173             notbuilt: true
174
175 - job-template:
176     name: '{project-name}-whitesource-scan-{stream}'
177     id: github-whitesource-scan
178     <<: *lf_whitesource_common
179     # yamllint disable-line rule:key-duplicates
180     <<: *lf_wss_unified_agent_scan
181
182     properties:
183       - lf-infra-properties:
184           build-days-to-keep: '{build-days-to-keep}'
185       - github:
186           url: '{github-url}/{github-org}/{project}'
187
188     scm:
189       - lf-infra-github-scm:
190           url: '{git-clone-url}{github-org}/{project}'
191           refspec: ''
192           branch: 'refs/heads/{branch}'
193           submodule-recursive: '{submodule-recursive}'
194           submodule-timeout: '{submodule-timeout}'
195           choosing-strategy: default
196           jenkins-ssh-credential: '{jenkins-ssh-credential}'
197
198     triggers:
199       # Build weekly on Saturdays
200       - timed: '{obj:cron}'
201       - github-pull-request:
202           trigger-phrase: '^run-whitesource$'
203           only-trigger-phrase: false
204           status-context: 'WhiteSource'
205           permit-all: true
206           github-hooks: true
207           white-list-target-branches:
208             - '{branch}'
209           included-regions: '{obj:github_included_regions}'