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