From cf2e68b555d8cf3d6acaa223d08c521e75b1a67b Mon Sep 17 00:00:00 2001 From: Zhenya Tikhonov Date: Thu, 12 Nov 2026 16:06:18 +0400 Subject: [PATCH] fix(codefresh-run): fix `TERMINATE_ON_TIMEOUT` --- graduated/codefresh-run/step.yaml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/graduated/codefresh-run/step.yaml b/graduated/codefresh-run/step.yaml index a0da36eeb..3af01648c 100644 --- a/graduated/codefresh-run/step.yaml +++ b/graduated/codefresh-run/step.yaml @@ -3,7 +3,7 @@ kind: step-type metadata: name: codefresh-run title: Run a Codefresh pipeline - version: 1.6.2 + version: 1.6.3 isPublic: true description: Run a Codefresh pipeline by ID or name and attach the created build logs. sources: @@ -288,15 +288,16 @@ spec: [[- else ]] [[/* Terminate the child build only when the timeout is reached, not on other errors (e.g. API errors). */]] [[/* The timeout is detected by exit code 124 (CLI >= 1.3.0) or by the error message (older CLI versions exit with 1). */]] + [[/* Commands run with "set -e", so every failure that must not abort the script is caught with "||". */]] - >- - { codefresh wait --verbose $BUILD_ID --timeout [[(printf "%s" .Arguments.TIMEOUT_MINS)]] 2>&1; - echo $? > /tmp/codefresh-wait.rc; } | tee /tmp/codefresh-wait.log; - WAIT_RC=$(cat /tmp/codefresh-wait.rc 2>/dev/null); + { WAIT_RC=0; + codefresh wait --verbose $BUILD_ID --timeout [[(printf "%s" .Arguments.TIMEOUT_MINS)]] 2>&1 || WAIT_RC=$?; + echo $WAIT_RC > /tmp/codefresh-wait.rc; } | tee /tmp/codefresh-wait.log; + WAIT_RC=$(cat /tmp/codefresh-wait.rc 2>/dev/null || echo 1); if [ "$WAIT_RC" != "0" ]; then - WAIT_RC=${WAIT_RC:-1}; if [ "$WAIT_RC" -eq 124 ] || grep -q "Operation has timed out" /tmp/codefresh-wait.log; then echo "TERMINATE_ON_TIMEOUT was set to true, sending termination request"; - codefresh terminate $BUILD_ID; + codefresh terminate $BUILD_ID || echo "Failed to terminate build $BUILD_ID"; fi; exit $WAIT_RC; fi