Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
maven: circleci/maven@2.0.0
Use maven
elements in your existing workflows and jobs.
Use parameters to run custom Maven commands. In the example below we are running maven verify with debug mode enabled.
1
2
3
4
5
6
7
8
version: '2.1'
orbs:
maven: circleci/maven@x.y
workflows:
maven_test:
jobs:
- maven/test:
command: '-X verify'
If your tests results are not in the default (target/surefire-reports) directory then you could add a custom directory.
1
2
3
4
5
6
7
8
version: '2.1'
orbs:
maven: circleci/maven@x.y
workflows:
maven_test:
jobs:
- maven/test:
test_results_path: /path/to/test/results
If you have a standard maven project, you can use this orb to run through a common maven workflow. Without any additional configuration you can build, test, and automatically have your test results uploaded to CircleCI.
1
2
3
4
5
6
7
version: '2.1'
orbs:
maven: circleci/maven@x.y
workflows:
maven_test:
jobs:
- maven/test
This example shows how to use the matrix key to launch against multiple cimg/openjdk images.
1
2
3
4
5
6
7
8
9
10
11
12
version: '2.1'
orbs:
maven: circleci/maven@1.1
workflows:
maven_test:
jobs:
- maven/test:
matrix:
parameters:
executor:
- j13
- j15
This example shows how to define an a custom executor for the maven/test job.
1
2
3
4
5
6
7
8
version: '2.1'
orbs:
maven: circleci/maven@1.1
workflows:
maven_test:
jobs:
- maven/test:
executor: example
Checkout, build, test, and upload test results for a Maven project spreading tests across multiple nodes
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
app_src_directory | The directory containing the pom.xml file for the project.
Useful when the source of your maven project is not in the root directory of your git repo.
| No | '' | string |
cache_name | The cache's name prefix to allow for multiple caches and/or cache invalidation. | No | maven | string |
command | The maven command(s) to run. Multiple commands can be run by providing a multi-line string. | No | verify | string |
dependency_plugin_version | Specify the Maven Dependency Plugin | No | 3.1.2 | string |
executor | The name of custom executor to use | No | default | executor |
maven_command | Specify a custom path for invoking maven | No | mvn | string |
mvn_step_name | The name given to the step that runs the maven command. | No | Run Tests | string |
parallel_it_pattern | This is the standard Failsafe pattern, but you can override
if you use alternate <includes> patterns in your pom.xml.
| No | '**/*IT*.java' | string |
parallel_test_pattern | This is the standard Surefire pattern, but you can override
if you use alternate <includes> patterns in your pom.xml
| No | '**/*Test*.java' | string |
parallelism | How many nodes should testing be split across? | No | 2 | integer |
post_mvn_steps | (Optional) Steps to run immediately after maven has completed, before test results are processed. | No | [] | steps |
pre_mvn_steps | (Optional) Steps to run just before maven, after the code has been checked out and the cache has been restored. | No | [] | steps |
settings_file | Specify a custom settings file to use (optional) | No | '' | string |
skip_checkout | Skip the checkout step if set to true. Useful when pre-steps are passed in to the job that will obtain the source code. | No | false | boolean |
test_directory | If following standard maven conventions this does not need to be changed. | No | src/test/java | string |
test_results_path | The path to the test results. | No | target/surefire-reports | string |
verify_dependencies | Verify dependencies are valid and available from public sources | No | true | boolean |
Checkout, build, test, and upload test results for a Maven project.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
app_src_directory | The directory containing the pom.xml file for the project.
Useful when the source of your maven project is not in the root directory of your git repo.
| No | '' | string |
cache_name | The cache's name prefix to allow for multiple caches and/or cache invalidation. | No | maven | string |
command | The maven command(s) to run. Multiple commands can be run by providing a multi-line string. | No | verify | string |
dependency_plugin_version | Specify the Maven Dependency Plugin | No | 3.1.2 | string |
executor | The name of custom executor to use | No | default | executor |
maven_command | Specify a custom path for invoking maven | No | mvn | string |
mvn_step_name | The name given to the step that runs the maven command. | No | Run Tests | string |
post_mvn_steps | (Optional) Steps to run immediately after maven has completed, before test results are processed. | No | [] | steps |
pre_mvn_steps | (Optional) Steps to run just before maven, after the code has been checked out and the cache has been restored. | No | [] | steps |
settings_file | Specify a custom settings file to use (optional) | No | '' | string |
skip_checkout | Skip the checkout step if set to true. Useful when pre-steps are passed in to the job that will obtain the source code. | No | false | boolean |
test_results_path | The path to the test results. | No | target/surefire-reports | string |
verify_dependencies | Verify dependencies are valid and available from public sources | No | true | boolean |
Upload test results. This will populate the Test Summary tab in the CircleCI UI. By default it will look in `target/surefire-reports` (the default location for maven test results). You can override where to find the test results with the path parameter.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
app_src_directory | The directory containing the pom.xml file for the project.
Useful when the source of your maven project is not in the root directory of your git repo.
This is ignored if test_results_path is an absolute path.
| No | '' | string |
test_results_path | Specify a custom path for maven test results | No | target/surefire-reports | string |
Run a set of steps with Maven dependencies cached. This command will first restore a cache of maven dependencies, if one was saved by a previous build. The provided `steps` parameter will then be executed, and if successful, then a fresh cache will be saved, if required. The contents of the `~/.m2/repository` directory is cached, which will substantially improve build times for projects with many dependencies. The cache-key is generated from any files named `pom.xml` that are present in the `working_directory`.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
app_src_directory | The directory containing the pom.xml file for the project.
Useful when the source of your maven project is not in the root directory of your git repo.
| No | '' | string |
cache_name | The cache's name prefix to allow for multiple caches and/or cache invalidation. | No | maven | string |
dependency_plugin_version | Specify the Maven Dependency Plugin | No | 3.1.2 | string |
maven_command | Specify a custom path for invoking maven | No | mvn | string |
settings_file | Specify a custom settings file to use (optional) | No | '' | string |
steps | - | Yes | - | steps |
verify_dependencies | Verify dependencies are valid and available from public sources | No | true | boolean |
CircleCI Java JDK image. Defaults to Java 17.0 and size "small".
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
resource_class | The resource class to use for the executor.
| No | small | string |
tag | Can be changed to any of the available tags listed on the DockerHub for this image.
https://hub.docker.com/r/cimg/openjdk/tags
| No | '17.0' | string |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
version: 2.1
description: |
Simplify common tasks for building and testing Java projects using Maven on CircleCI
display:
home_url: https://maven.apache.org/
source_url: https://github.com/CircleCI-Public/maven-orb
commands:
process_test_results:
description: |
Upload test results.
This will populate the Test Summary tab in the CircleCI UI. By default it will
look in `target/surefire-reports` (the default location for maven test results).
You can override where to find the test results with the path parameter.
parameters:
app_src_directory:
default: ""
description: |
The directory containing the pom.xml file for the project.
Useful when the source of your maven project is not in the root directory of your git repo.
This is ignored if test_results_path is an absolute path.
type: string
test_results_path:
default: target/surefire-reports
description: Specify a custom path for maven test results
type: string
steps:
- when:
condition:
matches:
pattern: ^/
value: << parameters.test_results_path >>
steps:
- store_test_results:
path: << parameters.test_results_path >>
- unless:
condition:
matches:
pattern: ^/
value: << parameters.test_results_path >>
steps:
- store_test_results:
path: << parameters.app_src_directory >><<#parameters.app_src_directory>>/<</parameters.app_src_directory>><< parameters.test_results_path >>
with_cache:
description: |
Run a set of steps with Maven dependencies cached.
This command will first restore a cache of maven dependencies, if one was
saved by a previous build. The provided `steps` parameter will then be executed, and
if successful, then a fresh cache will be saved, if required.
The contents of the `~/.m2/repository` directory is cached, which will substantially
improve build times for projects with many dependencies.
The cache-key is generated from any files named `pom.xml` that are
present in the `working_directory`.
parameters:
app_src_directory:
default: ""
description: |
The directory containing the pom.xml file for the project.
Useful when the source of your maven project is not in the root directory of your git repo.
type: string
cache_name:
default: maven
description: The cache's name prefix to allow for multiple caches and/or cache invalidation.
type: string
dependency_plugin_version:
default: 3.1.2
description: Specify the Maven Dependency Plugin
type: string
maven_command:
default: mvn
description: Specify a custom path for invoking maven
type: string
settings_file:
default: ""
description: Specify a custom settings file to use (optional)
type: string
steps:
type: steps
verify_dependencies:
default: true
description: Verify dependencies are valid and available from public sources
type: boolean
steps:
- run:
command: |-
#!/bin/bash
find . -name 'pom.xml' | sort | xargs cat > /tmp/maven_cache_seed
name: Generate Cache Checksum
working_directory: << parameters.app_src_directory >>
- restore_cache:
keys:
- << parameters.cache_name >>-{{ checksum "/tmp/maven_cache_seed" }}
- << parameters.cache_name >>-
- when:
condition: << parameters.verify_dependencies >>
steps:
- run:
command: |
#!/bin/bash
if [ -n "$PARAM_SETTINGS_FILE" ]; then
set -- "$@" --settings "$PARAM_SETTINGS_FILE"
fi
set -x
$PARAM_MVN_COMMAND org.apache.maven.plugins:maven-dependency-plugin:"$PARAM_DEP_PLUGIN_VER":go-offline "$@"
set +x
environment:
PARAM_DEP_PLUGIN_VER: << parameters.dependency_plugin_version >>
PARAM_MVN_COMMAND: << parameters.maven_command >>
PARAM_SETTINGS_FILE: << parameters.settings_file >>
name: Verify dependencies
working_directory: << parameters.app_src_directory >>
- steps: << parameters.steps >>
- save_cache:
key: << parameters.cache_name >>-{{ checksum "/tmp/maven_cache_seed" }}
paths:
- ~/.m2/repository
executors:
default:
description: |
CircleCI Java JDK image.
Defaults to Java 17.0 and size "small".
docker:
- image: cimg/openjdk:<<parameters.tag>>
parameters:
resource_class:
default: small
description: |
The resource class to use for the executor.
type: string
tag:
default: "17.0"
description: |
Can be changed to any of the available tags listed on the DockerHub for this image.
https://hub.docker.com/r/cimg/openjdk/tags
type: string
resource_class: <<parameters.resource_class>>
jobs:
parallel_test:
description: |
Checkout, build, test, and upload test results for a Maven project spreading tests across multiple nodes
executor: << parameters.executor >>
parallelism: << parameters.parallelism >>
parameters:
app_src_directory:
default: ""
description: |
The directory containing the pom.xml file for the project.
Useful when the source of your maven project is not in the root directory of your git repo.
type: string
cache_name:
default: maven
description: The cache's name prefix to allow for multiple caches and/or cache invalidation.
type: string
command:
default: verify
description: The maven command(s) to run. Multiple commands can be run by providing a multi-line string.
type: string
dependency_plugin_version:
default: 3.1.2
description: Specify the Maven Dependency Plugin
type: string
executor:
default: default
description: The name of custom executor to use
type: executor
maven_command:
default: mvn
description: Specify a custom path for invoking maven
type: string
mvn_step_name:
default: Run Tests
description: The name given to the step that runs the maven command.
type: string
parallel_it_pattern:
default: '**/*IT*.java'
description: |
This is the standard Failsafe pattern, but you can override
if you use alternate <includes> patterns in your pom.xml.
type: string
parallel_test_pattern:
default: '**/*Test*.java'
description: |
This is the standard Surefire pattern, but you can override
if you use alternate <includes> patterns in your pom.xml
type: string
parallelism:
default: 2
description: How many nodes should testing be split across?
type: integer
post_mvn_steps:
default: []
description: (Optional) Steps to run immediately after maven has completed, before test results are processed.
type: steps
pre_mvn_steps:
default: []
description: (Optional) Steps to run just before maven, after the code has been checked out and the cache has been restored.
type: steps
settings_file:
default: ""
description: Specify a custom settings file to use (optional)
type: string
skip_checkout:
default: false
description: Skip the checkout step if set to true. Useful when pre-steps are passed in to the job that will obtain the source code.
type: boolean
test_directory:
default: src/test/java
description: If following standard maven conventions this does not need to be changed.
type: string
test_results_path:
default: target/surefire-reports
description: The path to the test results.
type: string
verify_dependencies:
default: true
description: Verify dependencies are valid and available from public sources
type: boolean
steps:
- unless:
condition: << parameters.skip_checkout >>
steps:
- checkout
- run:
command: "#!/bin/bash\nset -eo pipefail\necho -e \"\\033[31m\\033[4mOrb Notes on Test Splitting\\033[0m\n \\033[34mCaveat 1:\\033[0m CircleCI Test Splitting uses filename by default, but JUnit reports use class names.\n Therefore this orb uses naive translation of linux file paths to dot separated package names and strips the .java suffix.\n \\033[34mCaveat 2:\\033[0m Surefire and Failsafe both allow <includes> in pom configuration (which can come from parent projects).\n These values are appended to any -DincludeFiles argument (meaning it would still run all tests on every node).\n Therefore this orb will generate an exclusion list; a list of tests being run on the other nodes, and pass that to surefire/failsafe as an exclusion.\n \\033[34mDebugging:\\033[0m This orb will place all files used to decide tests in .circleci/tests. Export it as an artifact for inspection/debugging.\n \"\nif [ -n \"${PARAM_APP_SRC_DIR}\" ]; then\n ( # show the user where we are cd'ing to\n set -x\n cd \"${PARAM_APP_SRC_DIR}\"\n )\n # but then do it again so it affects us not just a subshell\n cd \"${PARAM_APP_SRC_DIR}\" || exit\nfi\nset -u # delay setting this until after cd as some CircleCI cd hooks fail with it set\n(\n set -x\n mkdir -p .circleci/tests/\n)\n\n# generate excluded surefire tests using provided pattern\n(\n set -x\n circleci tests glob \"${PARAM_TEST_DIR}/${PARAM_TEST_PATTERN}\" | \\\n sed \"s#.*src/test/java/\\(.*\\)\\..*#\\1#g\" | \\\n tr \"/\" \".\" > .circleci/tests/surefire_classnames\n circleci tests split --split-by=timings --timings-type=classname < .circleci/tests/surefire_classnames > /tmp/this_node_tests \n grep -xvf /tmp/this_node_tests < .circleci/tests/surefire_classnames > .circleci/tests/surefire_classnames_ignore_list || true\n)\n# Note: grep returns a non-zero exit code if no lines are matched, hence the || true.\n# We don't mind no matches as we might not have both surefire and failsafe tests.\n\n# generate excluded failsafe tests using provided pattern\n(\n set -x\n circleci tests glob \"${PARAM_TEST_DIR}/${PARAM_IT_PATTERN}\" | \\\n sed \"s#.*src/test/java/\\(.*\\)\\..*#\\1#g\" | \\\n tr \"/\" \".\" > .circleci/tests/failsafe_classnames\n circleci tests split --split-by=timings --timings-type=classname < .circleci/tests/failsafe_classnames > /tmp/this_node_it_tests\n grep -xvf /tmp/this_node_it_tests < .circleci/tests/failsafe_classnames > .circleci/tests/failsafe_classnames_ignore_list || true\n)\n\necho\nif [ -s .circleci/tests/surefire_classnames ]; then\n echo \"# Surefire tests:\"\n cat .circleci/tests/surefire_classnames\n if [ -s .circleci/tests/surefire_classnames_ignore_list ]; then\n echo\n echo \"# Excluded Surefire tests:\"\n cat .circleci/tests/surefire_classnames_ignore_list\n else\n echo \"# No Surefire tests are excluded.\"\n fi\nelse\n echo \"# No Surefire tests found in ${PARAM_TEST_DIR}/${PARAM_TEST_PATTERN}\"\nfi\n\necho\nif [ -s .circleci/tests/failsafe_classnames ]; then\n echo \"# Failsafe tests:\"\n cat .circleci/tests/failsafe_classnames\n if [ -s .circleci/tests/failsafe_classnames_ignore_list ]; then\n echo\n echo \"# Excluded Failsafe tests:\"\n cat .circleci/tests/failsafe_classnames_ignore_list\n else\n echo \"# No Failsafe tests are excluded.\"\n fi\nelse\n echo \"# No Failsafe tests found in ${PARAM_TEST_DIR}/${PARAM_IT_PATTERN}\"\nfi\n"
environment:
PARAM_APP_SRC_DIR: << parameters.app_src_directory >>
PARAM_IT_PATTERN: << parameters.parallel_it_pattern >>
PARAM_TEST_DIR: << parameters.test_directory >>
PARAM_TEST_PATTERN: << parameters.parallel_test_pattern >>
name: Enable Test Splitting
- store_artifacts:
path: .circleci/tests/
- with_cache:
app_src_directory: << parameters.app_src_directory >>
cache_name: << parameters.cache_name >>
dependency_plugin_version: << parameters.dependency_plugin_version >>
maven_command: << parameters.maven_command >>
settings_file: << parameters.settings_file >>
steps:
- steps: << parameters.pre_mvn_steps >>
- run:
command: |
#!/bin/bash
# If we're being run by the parallel_test command then this env will be set and we need to
# tell maven where to find the ignore lists so that we only run the tests that we're supposed to
if [ -n "$PARAM_PARALLEL_IGNORE_LISTS_EXIST" ]; then
set -- "$@" -Dsurefire.excludesFile=.circleci/tests/surefire_classnames_ignore_list -Dfailsafe.excludesFile=.circleci/tests/failsafe_classnames_ignore_list
fi
if [ -n "$PARAM_SETTINGS_FILE" ]; then
set -- "$@" --settings "$PARAM_SETTINGS_FILE"
fi
# Loop over each line in PARAM_COMMAND
printf '%s\n' "$PARAM_COMMAND" | while IFS= read -r LINE_FROM_PARAM_COMMAND; do
# Strip leading and trailing whitespace
TRIMMED_LINE_FROM_PARAM_COMMAND=$(echo "$LINE_FROM_PARAM_COMMAND" | xargs)
# Check if the line is not empty
if [ -n "$TRIMMED_LINE_FROM_PARAM_COMMAND" ]; then
# Invoke the command with the trimmed line and additional arguments
(
set -x
# shellcheck disable=SC2086
$PARAM_MVN_COMMAND $TRIMMED_LINE_FROM_PARAM_COMMAND "$@"
) || exit 1
fi
done
environment:
PARAM_COMMAND: << parameters.command >>
PARAM_MVN_COMMAND: << parameters.maven_command >>
PARAM_PARALLEL_IGNORE_LISTS_EXIST: "true"
PARAM_SETTINGS_FILE: << parameters.settings_file >>
name: << parameters.mvn_step_name >>
working_directory: << parameters.app_src_directory >>
- steps: << parameters.post_mvn_steps >>
verify_dependencies: << parameters.verify_dependencies >>
- process_test_results:
app_src_directory: << parameters.app_src_directory >>
test_results_path: << parameters.test_results_path >>
test:
description: |
Checkout, build, test, and upload test results for a Maven project.
executor: <<parameters.executor>>
parameters:
app_src_directory:
default: ""
description: |
The directory containing the pom.xml file for the project.
Useful when the source of your maven project is not in the root directory of your git repo.
type: string
cache_name:
default: maven
description: The cache's name prefix to allow for multiple caches and/or cache invalidation.
type: string
command:
default: verify
description: The maven command(s) to run. Multiple commands can be run by providing a multi-line string.
type: string
dependency_plugin_version:
default: 3.1.2
description: Specify the Maven Dependency Plugin
type: string
executor:
default: default
description: The name of custom executor to use
type: executor
maven_command:
default: mvn
description: Specify a custom path for invoking maven
type: string
mvn_step_name:
default: Run Tests
description: The name given to the step that runs the maven command.
type: string
post_mvn_steps:
default: []
description: (Optional) Steps to run immediately after maven has completed, before test results are processed.
type: steps
pre_mvn_steps:
default: []
description: (Optional) Steps to run just before maven, after the code has been checked out and the cache has been restored.
type: steps
settings_file:
default: ""
description: Specify a custom settings file to use (optional)
type: string
skip_checkout:
default: false
description: Skip the checkout step if set to true. Useful when pre-steps are passed in to the job that will obtain the source code.
type: boolean
test_results_path:
default: target/surefire-reports
description: The path to the test results.
type: string
verify_dependencies:
default: true
description: Verify dependencies are valid and available from public sources
type: boolean
steps:
- unless:
condition: << parameters.skip_checkout >>
steps:
- checkout
- with_cache:
app_src_directory: << parameters.app_src_directory >>
cache_name: << parameters.cache_name >>
dependency_plugin_version: << parameters.dependency_plugin_version >>
maven_command: << parameters.maven_command >>
settings_file: << parameters.settings_file >>
steps:
- steps: << parameters.pre_mvn_steps >>
- run:
command: |
#!/bin/bash
# If we're being run by the parallel_test command then this env will be set and we need to
# tell maven where to find the ignore lists so that we only run the tests that we're supposed to
if [ -n "$PARAM_PARALLEL_IGNORE_LISTS_EXIST" ]; then
set -- "$@" -Dsurefire.excludesFile=.circleci/tests/surefire_classnames_ignore_list -Dfailsafe.excludesFile=.circleci/tests/failsafe_classnames_ignore_list
fi
if [ -n "$PARAM_SETTINGS_FILE" ]; then
set -- "$@" --settings "$PARAM_SETTINGS_FILE"
fi
# Loop over each line in PARAM_COMMAND
printf '%s\n' "$PARAM_COMMAND" | while IFS= read -r LINE_FROM_PARAM_COMMAND; do
# Strip leading and trailing whitespace
TRIMMED_LINE_FROM_PARAM_COMMAND=$(echo "$LINE_FROM_PARAM_COMMAND" | xargs)
# Check if the line is not empty
if [ -n "$TRIMMED_LINE_FROM_PARAM_COMMAND" ]; then
# Invoke the command with the trimmed line and additional arguments
(
set -x
# shellcheck disable=SC2086
$PARAM_MVN_COMMAND $TRIMMED_LINE_FROM_PARAM_COMMAND "$@"
) || exit 1
fi
done
environment:
PARAM_COMMAND: << parameters.command >>
PARAM_MVN_COMMAND: << parameters.maven_command >>
PARAM_SETTINGS_FILE: << parameters.settings_file >>
name: << parameters.mvn_step_name >>
working_directory: << parameters.app_src_directory >>
- steps: << parameters.post_mvn_steps >>
verify_dependencies: << parameters.verify_dependencies >>
- process_test_results:
app_src_directory: << parameters.app_src_directory >>
test_results_path: << parameters.test_results_path >>
examples:
custom_command:
description: |
Use parameters to run custom Maven commands. In the example below we are running maven verify with debug mode enabled.
usage:
version: "2.1"
orbs:
maven: circleci/maven@x.y
workflows:
maven_test:
jobs:
- maven/test:
command: -X verify
custom_test_results_path:
description: |
If your tests results are not in the default (target/surefire-reports) directory then you could add a custom directory.
usage:
version: "2.1"
orbs:
maven: circleci/maven@x.y
workflows:
maven_test:
jobs:
- maven/test:
test_results_path: /path/to/test/results
maven_test:
description: |
If you have a standard maven project, you can use this orb to run through a common maven workflow. Without any additional configuration you can build, test, and automatically have your test results uploaded to CircleCI.
usage:
version: "2.1"
orbs:
maven: circleci/maven@x.y
workflows:
maven_test:
jobs:
- maven/test
test_executor_matrix:
description: |
This example shows how to use the matrix key to launch against multiple
cimg/openjdk images.
usage:
version: "2.1"
orbs:
maven: circleci/maven@1.1
workflows:
maven_test:
jobs:
- maven/test:
matrix:
parameters:
executor:
- j13
- j15
test_with_executor:
description: |
This example shows how to define an a custom executor for the maven/test job.
usage:
version: "2.1"
orbs:
maven: circleci/maven@1.1
workflows:
maven_test:
jobs:
- maven/test:
executor: example