https://github.com/monkey-projects/plugin-junit
MonkeyCI extension to handle junit results
https://github.com/monkey-projects/plugin-junit
Last synced: 4 months ago
JSON representation
MonkeyCI extension to handle junit results
- Host: GitHub
- URL: https://github.com/monkey-projects/plugin-junit
- Owner: monkey-projects
- License: mit
- Created: 2024-04-29T12:23:03.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-09-11T06:58:35.000Z (9 months ago)
- Last Synced: 2026-02-18T17:36:20.479Z (4 months ago)
- Language: Clojure
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MonkeyCI JUnit Plugin
This is a Clojure library that provides plugin functionality for [MonkeyCI](https://monkeyci.com)
to allow build jobs to extract information from JUnit test results so they can be added to the
build results. The plugin reads a `junit.xml` compatible file from a configured artifact and
parses the information.
## Usage
[](https://clojars.org/com.monkeyci/plugin-junit)
First include the library in your build `deps.edn`:
```clojure
{:deps {com.monkeyci/plugin-junit {:mvn/version "VERSION"}}}
```
Then make sure you `require` it in your build script. It registers itself on a tag
named `junit`, which should contain the necessary configuration. For example:
```clojure
(ns build
(:require [monkey.ci.ext.junit :as j]
[monkey.ci.api :as m]))
;; Some build job
(def test-job
(-> (m/container-job "run-tests")
(m/image "docker.io/clojure")
(m/script ["lein test-junit"])
(m/save-artifacts [(m/artifact "test-results" "junit.xml")])
;; Configuration for the plugin
;; Alternatively, you can use {:artifact-id "test-results" :path "junit.xml"}
(j/junit (m/artifact "test-results" "junit.xml"))))
;; Jobs in your build script
[test-job]
```
The plugin will read the artifact with id `test-results` and extract the `junit.xml` file
from it, parsing it as xml. The information is added to the build job results under the
key `monkey.ci/tests`.
### Multiple Files
Many test tools, such as [Apache Maven](https://maven.apache.org/) will generate multiple
test result files in a directory. It's possible to specify a `pattern` instead of a `path`
for these situations. The extension will then look up all files matching the pattern in the
archive, and consolidate all extracted test results.
```clojure
;; Some build job
(def test-job
(-> (m/container-job "run-tests")
(m/image "docker.io/maven:latest")
(m/script ["mvn verify"])
(m/save-artifacts [(m/artifact "test-results" "target/surefire-reports")])
;; Configuration for the plugin
(j/junit {:artifact-id "test-results"
;; Use regex pattern instead of path
:pattern #"surefire-reports/.*.xml"})))
```
## License
Copyright (c) 2024-2025 by [Monkey Projects](https://www.monkey-projects.be).
[MIT License](LICENSE)