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