File tree Expand file tree Collapse file tree 4 files changed +53
-12
lines changed Expand file tree Collapse file tree 4 files changed +53
-12
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,12 @@ The docker image to use for running the analysis code. Must be a valid image ref
108108
109109Default : ` ruby:3.1-alpine@sha256:a39e26d0598837f08c75a42c8b0886d9ed5cc862c4b535662922ee1d05272fca`
110110
111+ # ## `run-in-docker` (optional, boolean)
112+
113+ Default : ` true`
114+
115+ 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.
116+
111117# # Developing
112118
113119To run testing, shellchecks and plugin linting use use `bk run` with the [Buildkite CLI](https://github.com/buildkite/cli).
Original file line number Diff line number Diff line change 4242echo " --- :junit: Processing the junits"
4343
4444set +e
45- docker \
46- --log-level " error" \
47- run \
48- --rm \
49- --volume " $artifacts_dir :/junits" \
50- --volume " $PLUGIN_DIR /ruby:/src" \
51- --env " BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN=${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN:- } " \
52- --env " BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT=${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT:- } " \
53- --env " BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST=${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST:- } " \
54- --env " BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SKIPPED=${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SKIPPED:- } " \
55- " ${RUBY_IMAGE} " ruby /src/bin/annotate /junits \
56- > " $annotation_path "
45+ if [[ " ${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_RUN_IN_DOCKER:- true} " =~ " true" ]]; then
46+ docker \
47+ --log-level " error" \
48+ run \
49+ --rm \
50+ --volume " $artifacts_dir :/junits" \
51+ --volume " $PLUGIN_DIR /ruby:/src" \
52+ --env " BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN=${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN:- } " \
53+ --env " BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT=${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT:- } " \
54+ --env " BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST=${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST:- } " \
55+ --env " BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SKIPPED=${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SKIPPED:- } " \
56+ " ${RUBY_IMAGE} " ruby /src/bin/annotate /junits \
57+ > " $annotation_path "
58+ else
59+ ruby " ${PLUGIN_DIR} /ruby/bin/annotate" " ${artifacts_dir} " > " $annotation_path "
60+ fi
5761
5862exit_code=$?
5963set -e
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ configuration:
3030 type : integer
3131 ruby-image :
3232 type : string
33+ run-in-docker :
34+ type : boolean
3335 required :
3436 - artifacts
3537 additionalProperties : false
Original file line number Diff line number Diff line change @@ -527,4 +527,33 @@ DOCKER_STUB_DEFAULT_OPTIONS='--log-level error run --rm --volume \* --volume \*
527527 unstub buildkite-agent
528528 unstub docker
529529 rm " ${annotation_input} "
530+ }
531+
532+ @test " does not run in docker when run-in-docker is false" {
533+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS=" junits/*.xml"
534+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAIL_BUILD_ON_ERROR=false
535+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_RUN_IN_DOCKER=false
536+
537+ stub mktemp \
538+ " -d \* : mkdir -p '$artifacts_tmp '; echo '$artifacts_tmp '" \
539+ " -d \* : mkdir -p '$annotation_tmp '; echo '$annotation_tmp '"
540+
541+ stub buildkite-agent \
542+ " artifact download \* \* : echo Downloaded artifact \$ 3 to \$ 4" \
543+ " annotate --context \* --style \* : cat >'${annotation_input} '; echo Annotation added with context \$ 3 and style \$ 5, content saved"
544+
545+ stub ruby \
546+ " /plugin/hooks/../ruby/bin/annotate /plugin/${artifacts_tmp} : echo '<details>Failure</details>' && exit 64"
547+
548+ run " $PWD /hooks/command"
549+
550+ assert_success
551+
552+ assert_output --partial " Annotation added with context junit and style error"
553+ assert_equal " $( cat " ${annotation_input} " ) " ' <details>Failure</details>'
554+
555+ unstub mktemp
556+ unstub buildkite-agent
557+ unstub ruby
558+ rm " ${annotation_input} "
530559}
You can’t perform that action at this time.
0 commit comments