A Buildkite plugin that parses junit.xml artifacts (generated across any number of parallel steps) and creates a build annotation listing the individual tests that failed.
The following pipeline will run test.sh jobs in parallel, and then process all the resulting JUnit XML files to create a summary build annotation.
steps:
- command: test.sh
parallelism: 50
artifact_paths: tmp/junit-*.xml
- wait: ~
continue_on_failure: true
- plugins:
- junit-annotate#v3.0.0:
artifacts: tmp/junit-*.xmlTo create separate annotations for different test suites, call the plugin multiple times with different contexts:
steps:
- command: test.sh
parallelism: 50
artifact_paths: tmp/junit-*.xml
- command: anothertest.sh
artifact_paths: artifacts/junit-*.xml
- wait: ~
continue_on_failure: true
- plugins:
- junit-annotate#v3.0.0:
artifacts: tmp/junit-*.xml
- plugins:
- junit-annotate#v3.0.0:
artifacts: artifacts/junit-*.xml
context: junit-artifactsThe artifact glob path to find the JUnit XML files.
Example: tmp/junit-*.xml
Forces the creation of the annotation even when no failures or errors are found
Default: junit
The buildkite annotation context to use. Useful to differentiate multiple runs of this plugin in a single pipeline.
Exclude failure, error, and skipped results for tests whose JUnit testcase name contains any of the supplied strings. Matching is case-sensitive and literal: punctuation has no special meaning. Empty strings are not allowed. Omitting this option or supplying an empty array leaves all results included.
exclude-tests:
- "checkout with expired card"
- "refund during maintenance"Excluded results are omitted from the detailed lists and the failure, error, and skipped counts. They do not trigger fail-build-on-error or error styling. The plugin reports Excluded tests: N when it excludes unsuccessful tests, counting each testcase once even if it contains multiple results. Matching passing tests are not counted as excluded.
Total tests still includes every testcase, so min-tests is unchanged. Slowest-test reporting also includes excluded tests. This option does not change the original test step's exit status or the JUnit artifacts.
Exclusions alone do not force an annotation. Use always-annotate: true to display the summary when no non-excluded failures or errors remain. The summary is also printed in the annotation step's job log.
Adds a heading before the test summary. The title is displayed as literal text, not HTML or Markdown. No heading is added when the title is unset or empty; the context is not used as a default title.
Configure each plugin invocation with a distinct context and title, for example:
artifacts: tmp/junit-*.xml
context: unit-tests
title: Unit test resultsA title does not force an annotation to be created or change its context. Use distinct contexts for separate annotations. Titles are retained when oversized reports are simplified, but the replacement notice created by add-error-annotation remains generic.
Default: -(.*).xml
The regular expression (with capture group) that matches the job UUID in the junit file names. This is used to create the job links in the annotation.
To use this, configure your test reporter to embed the $BUILDKITE_JOB_ID environment variable into your junit file names. For example "junit-buildkite-job-$BUILDKITE_JOB_ID.xml".
This setting controls the format of your failed test in the main annotation summary.
There are two options for this:
classname(the default)- displays:
MyClass::UnderTest text of the failed expectation in path.to.my_class.under_test
- displays:
file- displays:
MyClass::UnderTest text of the failed expectation in path/to/my_class/under_test.file_ext
- displays:
Default: false
If this setting is true and any errors are found in the JUnit XML files during parsing, the annotation step will exit with a non-zero value, which should cause the build to fail.
Default: 2
Exit code of the plugin if the call to buildkite-agent artifact download fails.
Default: false
If true and there is an issue with generating annotations, output an error to let the user know.
Default: 1024 (kb)
Maximum size of test output to handle.
Minimum amount of run tests that need to be analyzed or a failure will be reported. It is useful to ensure that tests are actually run and report files to analyze do contain information.
Default: false
Will add a list of skipped tests at the end of the annotation. Note that even if there are skipped tests, the annotation may not be added unless other options or results of the processing forces it to.
Default: 0
Include the specified number of slowest tests in the annotation. The annotation will always be shown.
The docker image to use for running the analysis code. Must be a valid image reference that can run the corresponding ruby code and the agent running the step must be able to pull it if not already present.
Default: ruby:4.0.9-alpine@sha256:d0c5befc0864d31c6219321c8d79de2941d1bc31c41505d9c9289c6192c36d60
Default: true
Controls whether the JUnit processing should run inside a Docker container. When set to false, the processing will run directly on the host using the system's Ruby installation.
Default: info
The style to use for annotations.
| Elastic Stack | Agent Stack K8s | Hosted (Mac) | Hosted (Linux) | Notes |
|---|---|---|---|---|
| β | β | K8s - Out of the box, requires run-in-docker: false and a container image with ruby installedLikely requires some complex podSpec (pending investigation) Hosted (Mac) - instances do not ship with the Docker daemon, but can use a ruby binary on the agent |
- β Fully supported (all combinations of attributes have been tested to pass)
β οΈ Partially supported (some combinations cause errors/issues)- β Not supported
To run testing, shellchecks and plugin linting use use bk run with the Buildkite CLI.
bk runOr if you want to run just the plugin tests, you can use the docker Plugin Tester:
docker run --rm -ti -v "${PWD}":/plugin buildkite/plugin-tester:latestTo test the Ruby code with rake in docker:
docker-compose run --rm rubyTo test your plugin in your builds prior to opening a pull request, you can refer to your fork and SHA from a branch in your pipeline.yml.
steps:
- label: Annotate
plugins:
- YourGithubHandle/junit-annotate#v3.0.0:
...
MIT (see LICENSE)