Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions graduated/codefresh-run/step.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: step-type
metadata:
name: codefresh-run
title: Run a Codefresh pipeline
version: 1.6.0
version: 1.6.1
isPublic: true
description: Run a Codefresh pipeline by ID or name and attach the created build logs.
sources:
Expand Down Expand Up @@ -160,7 +160,7 @@ spec:
},
"TERMINATE_ON_TIMEOUT": {
"type": "boolean",
"description": "Terminate build if timeout reached",
"description": "Terminate build if timeout reached. Other errors (e.g. failed API requests) do not terminate the build",
"default": false
},
"ONLY": {
Expand Down Expand Up @@ -262,11 +262,23 @@ spec:
- echo "Retrieving logs for build $BUILD_ID"
- codefresh logs -f --no-timestamps $BUILD_ID
[[- end ]]
[[- if eq .Arguments.TERMINATE_ON_TIMEOUT false ]]
- >-
codefresh wait --verbose $BUILD_ID --timeout [[(printf "%s" .Arguments.TIMEOUT_MINS)]]
[[- if eq .Arguments.TERMINATE_ON_TIMEOUT true ]]
|| (echo "TERMINATE_ON_TIMEOUT was set to true, sending termination request" &&
codefresh terminate $BUILD_ID &&
exit 1)
[[- 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). */]]
- >-
{ 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);
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;
fi;
exit $WAIT_RC;
fi
[[- end ]]
[[- end -]]
Loading