diff --git a/graduated/codefresh-run/step.yaml b/graduated/codefresh-run/step.yaml index 917885e97..da920762d 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.0 + version: 1.6.1 isPublic: true description: Run a Codefresh pipeline by ID or name and attach the created build logs. sources: @@ -248,8 +248,11 @@ spec: [[/* Multiline string is required to support usage of 'colon' (:) character in the string. For example in the pipeline name. */]] [[/* Otherwise after template render there is a chance to have an object instead of a string. */]] - >- - CLI_OUTPUT=$([[ $cmd ]]) && - export BUILD_ID=$(echo "$CLI_OUTPUT" | tail -n 1); if [ -z "$BUILD_ID" ]; then exit 1; fi + CLI_OUTPUT=$([[ $cmd ]] 2>&1); CLI_EXIT_CODE=$?; + echo "$CLI_OUTPUT"; + export BUILD_ID=$(echo "$CLI_OUTPUT" | tail -n 1); + if [ "$CLI_EXIT_CODE" -ne 0 ]; then echo "codefresh-run: the Codefresh CLI exited with code $CLI_EXIT_CODE, see the output above."; exit "$CLI_EXIT_CODE"; fi; + if [ -z "$BUILD_ID" ]; then echo "codefresh-run: the Codefresh CLI succeeded but returned no build id, so no child build was created. This is expected when the parent build is already terminating; run the CLI in a freestyle step if the step must survive termination."; exit 1; fi - cf_export first_CF_OUTPUT_URL="${{CF_URL}}/build/$BUILD_ID" - cf_export BUILD_ID [[- if eq .Arguments.DETACH false ]]