diff --git a/README.md b/README.md
index 3667f1a..cda3914 100644
--- a/README.md
+++ b/README.md
@@ -70,6 +70,12 @@ Default: `0`
Include the specified number of slowest tests in the annotation. The annotation will always be shown.
+### `ruby-image` (optional)
+
+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:3.1-alpine@sha256:a39e26d0598837f08c75a42c8b0886d9ed5cc862c4b535662922ee1d05272fca`
+
## Developing
To test the plugin hooks (in Bash) and the junit parser (in Ruby):
diff --git a/hooks/command b/hooks/command
index 44be66d..0bd9899 100755
--- a/hooks/command
+++ b/hooks/command
@@ -9,6 +9,7 @@ fi
PLUGIN_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)/.."
MAX_SIZE=1024 # in KB
+RUBY_IMAGE="${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_RUBY_IMAGE:-'ruby:3.1-alpine@sha256:a39e26d0598837f08c75a42c8b0886d9ed5cc862c4b535662922ee1d05272fca'}"
artifacts_dir="$(pwd)/$(mktemp -d "junit-annotate-plugin-artifacts-tmp.XXXXXXXXXX")"
annotation_dir="$(pwd)/$(mktemp -d "junit-annotate-plugin-annotation-tmp.XXXXXXXXXX")"
@@ -49,7 +50,7 @@ docker \
--env "BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN=${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN:-}" \
--env "BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT=${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT:-}" \
--env "BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST=${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST:-}" \
- ruby:2.7-alpine ruby /src/bin/annotate /junits \
+ "${RUBY_IMAGE}" ruby /src/bin/annotate /junits \
> "$annotation_path"
exit_code=$?
diff --git a/plugin.yml b/plugin.yml
index 1dcaf76..be71671 100644
--- a/plugin.yml
+++ b/plugin.yml
@@ -24,6 +24,8 @@ configuration:
type: integer
report-slowest:
type: integer
+ ruby-image:
+ type: string
required:
- artifacts
additionalProperties: false
diff --git a/tests/command.bats b/tests/command.bats
index e63dc51..564d813 100644
--- a/tests/command.bats
+++ b/tests/command.bats
@@ -25,7 +25,7 @@ export annotation_input="tests/tmp/annotation.input"
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
stub docker \
- "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : echo 'Failure ' && exit 64"
+ "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : echo 'Failure ' && exit 64"
run "$PWD/hooks/command"
@@ -53,7 +53,7 @@ export annotation_input="tests/tmp/annotation.input"
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
stub docker \
- "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
+ "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
run "$PWD/hooks/command"
@@ -80,7 +80,7 @@ export annotation_input="tests/tmp/annotation.input"
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
stub docker \
- "--log-level error run --rm --volume \* --volume \* --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN='custom_(*)_pattern.xml' --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
+ "--log-level error run --rm --volume \* --volume \* --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN='custom_(*)_pattern.xml' --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
run "$PWD/hooks/command"
@@ -107,7 +107,7 @@ export annotation_input="tests/tmp/annotation.input"
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
stub docker \
- "--log-level error run --rm --volume \* --volume \* --env \* --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT='file' --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
+ "--log-level error run --rm --volume \* --volume \* --env \* --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT='file' --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
run "$PWD/hooks/command"
@@ -132,7 +132,7 @@ export annotation_input="tests/tmp/annotation.input"
"artifact download \* \* : echo Downloaded artifact \$3 to \$4"
stub docker \
- "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : echo 'Total tests: 0'"
+ "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : echo 'Total tests: 0'"
run "$PWD/hooks/command"
@@ -156,7 +156,7 @@ export annotation_input="tests/tmp/annotation.input"
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
stub docker \
- "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : echo 'Total tests: 0'"
+ "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : echo 'Total tests: 0'"
run "$PWD/hooks/command"
@@ -195,7 +195,7 @@ export annotation_input="tests/tmp/annotation.input"
"artifact download \* \* : echo Downloaded artifact \$3 to \$4"
stub docker \
- "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
+ "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
run "$PWD/hooks/command"
@@ -227,7 +227,7 @@ export annotation_input="tests/tmp/annotation.input"
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
stub docker \
- "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
+ "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
run "$PWD/hooks/command"
@@ -257,7 +257,7 @@ export annotation_input="tests/tmp/annotation.input"
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
stub docker \
- "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
+ "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
run "$PWD/hooks/command"
@@ -286,7 +286,7 @@ export annotation_input="tests/tmp/annotation.input"
"artifact download \* \* : echo Downloaded artifact \$3 to \$4"
stub docker \
- "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
+ "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
run "$PWD/hooks/command"
@@ -312,7 +312,7 @@ export annotation_input="tests/tmp/annotation.input"
"artifact download \* \* : echo Downloaded artifact \$3 to \$4"
stub docker \
- "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 147"
+ "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 147"
run "$PWD/hooks/command"
@@ -359,7 +359,7 @@ export annotation_input="tests/tmp/annotation.input"
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
stub docker \
- "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : echo 'Total tests: 0'"
+ "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : echo 'Total tests: 0'"
run "$PWD/hooks/command"
@@ -385,7 +385,7 @@ export annotation_input="tests/tmp/annotation.input"
"artifact download \* \* : echo Downloaded artifact \$3 to \$4"
stub docker \
- "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : echo 'Total tests: 100'"
+ "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : echo 'Total tests: 100'"
run "$PWD/hooks/command"
@@ -411,7 +411,7 @@ export annotation_input="tests/tmp/annotation.input"
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
stub docker \
- "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
+ "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
run "$PWD/hooks/command"
@@ -421,4 +421,32 @@ export annotation_input="tests/tmp/annotation.input"
unstub mktemp
unstub buildkite-agent
unstub docker
+}
+
+@test "runs the annotator and creates the annotation with special image" {
+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS="junits/*.xml"
+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_RUBY_IMAGE="ruby:special"
+
+ stub mktemp \
+ "-d \* : mkdir -p '$artifacts_tmp'; echo '$artifacts_tmp'" \
+ "-d \* : mkdir -p '$annotation_tmp'; echo '$annotation_tmp'"
+
+ stub buildkite-agent \
+ "artifact download \* \* : echo Downloaded artifact \$3 to \$4" \
+ "annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
+
+ stub docker \
+ "--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:special ruby /src/bin/annotate /junits : echo 'Failure ' && exit 64"
+
+ run "$PWD/hooks/command"
+
+ assert_success
+
+ assert_output --partial "Annotation added with context junit and style error"
+ assert_equal "$(cat "${annotation_input}")" 'Failure '
+
+ unstub mktemp
+ unstub buildkite-agent
+ unstub docker
+ rm "${annotation_input}"
}
\ No newline at end of file