Open
Conversation
Add a persistent container feature. When `reuse-container: true` is set, the plugin keeps a container alive across job steps instead of creating and destroying one each time. Key behaviors: - Derives a stable container name from the image name and agent spawn index (or uses an explicit `reuse-container-name` override). - On each job, checks for an existing running container: if the image digest matches, attaches via `docker exec`; if the digest differs, prints a warning banner, removes the stale container, and creates a fresh one. - New containers are started detached (`docker run -d ... sleep infinity`) with `--rm` suppressed, then the job command runs via `docker exec`. - Environment variables are stripped from the creation `docker run` and injected per-exec only, preventing secrets from leaking between jobs that share the container. - The `pre-exit` hook skips container cleanup when reuse-container is enabled so the container persists for subsequent jobs. Files changed: - plugin.yml: new `reuse-container` and `reuse-container-name` opts - lib/shared.bash: `get_reuse_container_name`, `get_container_image_id`, `get_image_id` helpers - commands/run.sh: reuse-container branch with exec-arg extraction, digest validation, and detached container creation - hooks/pre-exit: skip cleanup when reuse-container is set - tests/reuse-container.bats: 11 bats tests covering creation, reuse, digest mismatch, stopped container, custom name, spawn index, env passthrough, env stripping, pre-exit, --rm absence, and exit code propagation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a persistent container feature. When
reuse-container: trueis set, the plugin keeps a container alive across job steps
instead of creating and destroying one each time.
Key behaviors:
spawn index (or uses an explicit
reuse-container-nameoverride).image digest matches, attaches via
docker exec; if the digestdiffers, prints a warning banner, removes the stale container,
and creates a fresh one.
docker run -d ... sleep infinity) with--rmsuppressed, then the job command runs viadocker exec.docker runand injected per-exec only, preventing secrets from leaking
between jobs that share the container.
pre-exithook skips container cleanup when reuse-containeris enabled so the container persists for subsequent jobs.
Files changed:
reuse-containerandreuse-container-nameoptsget_reuse_container_name,get_container_image_id,get_image_idhelpersdigest validation, and detached container creation
reuse, digest mismatch, stopped container, custom name, spawn
index, env passthrough, env stripping, pre-exit, --rm absence,
and exit code propagation