From d5ec7af1a0d1b6b549179f9de693ea2cc9140d17 Mon Sep 17 00:00:00 2001 From: turegjorup Date: Tue, 16 Jun 2026 08:49:13 +0200 Subject: [PATCH 1/3] fix: propagate command exit code instead of swallowing failures execFileSync throws on a non-zero exit, but the catch block printed the error and returned, so the process exited 0 even when docker compose (and the command it ran) failed. Callers such as Ansible and Woodpecker then saw a successful run. Exit with the underlying command's status code, and exit non-zero when the env file is missing. This is the only command-execution path; it is a passthrough for all docker compose subcommands (run, exec, up, pull, ...), so the fix covers every command the wrapper runs. --- CHANGELOG.md | 4 ++++ src/commands/docker.ts | 2 +- src/modules/docker.ts | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 619d86e..19885ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +* Propagate the exit code from failed `docker compose` commands instead of + exiting 0, so callers (CI, Ansible) detect failures instead of seeing a + false success. + ## [0.0.14] - 2025-03-26 * [PR-10](https://github.com/itk-devops/devops_itkdev-docker-serverpull/1) diff --git a/src/commands/docker.ts b/src/commands/docker.ts index dba5787..8265b9a 100644 --- a/src/commands/docker.ts +++ b/src/commands/docker.ts @@ -14,7 +14,7 @@ exports.handler = function (argv: { [x: string]: any; base: string; debug: any; // Test env file exists. if (!utils.isFile(argv.base + '/' + env)) { console.error('The env file not found!'); - return; + process.exit(1); } // Hack to parse the commands that should be sendt to docker. diff --git a/src/modules/docker.ts b/src/modules/docker.ts index a937652..4867096 100644 --- a/src/modules/docker.ts +++ b/src/modules/docker.ts @@ -83,7 +83,11 @@ export default class Docker { if (err instanceof Error) { console.error(err.message); } - return null; + + // Propagate the failed command's exit code so callers (CI, Ansible) + // detect the failure instead of seeing a false success. + const status = (err as {status?: number | null}).status; + process.exit(typeof status === 'number' ? status : 1); } } } From 39f79c3c3cf1a079081b626758f4028afe01538b Mon Sep 17 00:00:00 2001 From: turegjorup Date: Tue, 16 Jun 2026 08:51:23 +0200 Subject: [PATCH 2/3] docs: add PR reference to changelog entry --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19885ba..a1cf845 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -* Propagate the exit code from failed `docker compose` commands instead of - exiting 0, so callers (CI, Ansible) detect failures instead of seeing a - false success. +* [PR-11](https://github.com/itk-devops/devops_itkdev-docker-server/pull/11) + Propagate command exit code instead of swallowing failed docker compose + commands. ## [0.0.14] - 2025-03-26 From 95501f5ea60b13e2a5d17d4e038b9a2ce0b7352a Mon Sep 17 00:00:00 2001 From: turegjorup Date: Tue, 16 Jun 2026 08:56:47 +0200 Subject: [PATCH 3/3] fix: include env file name in not-found error message --- src/commands/docker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/docker.ts b/src/commands/docker.ts index 8265b9a..05850f0 100644 --- a/src/commands/docker.ts +++ b/src/commands/docker.ts @@ -13,7 +13,7 @@ exports.handler = function (argv: { [x: string]: any; base: string; debug: any; // Test env file exists. if (!utils.isFile(argv.base + '/' + env)) { - console.error('The env file not found!'); + console.error(`The env (${env}) file not found!`); process.exit(1); }