diff --git a/.gitea/workflows/cd.yaml b/.gitea/workflows/cd.yaml index 4480a0826..b59d38e4e 100644 --- a/.gitea/workflows/cd.yaml +++ b/.gitea/workflows/cd.yaml @@ -1658,10 +1658,11 @@ jobs: local rc=1 while [ "${attempt}" -le "${max_attempts}" ]; do echo "cd_docker_push_attempt=${label}:${attempt}/${max_attempts}" - set +e - run_docker_step "${label}" "${timeout_seconds}" "$@" - rc=$? - set -e + if run_docker_step "${label}" "${timeout_seconds}" "$@"; then + rc=0 + else + rc=$? + fi if [ "${rc}" -eq 0 ]; then return 0 fi @@ -1733,10 +1734,11 @@ jobs: local rc=1 while [ "${attempt}" -le "${max_attempts}" ]; do echo "cd_docker_push_attempt=${label}:${attempt}/${max_attempts}" - set +e - run_docker_step "${label}" "${timeout_seconds}" "$@" - rc=$? - set -e + if run_docker_step "${label}" "${timeout_seconds}" "$@"; then + rc=0 + else + rc=$? + fi if [ "${rc}" -eq 0 ]; then return 0 fi diff --git a/ops/runner/test_cd_controlled_runtime_profile.py b/ops/runner/test_cd_controlled_runtime_profile.py index 0c0c14538..3a9935431 100644 --- a/ops/runner/test_cd_controlled_runtime_profile.py +++ b/ops/runner/test_cd_controlled_runtime_profile.py @@ -439,6 +439,16 @@ def test_cd_docker_build_and_push_steps_are_bounded_and_classified() -> None: assert "BLOCKER cd_docker_step_timeout label=${label}" in block assert 'CD_DOCKER_PUSH_ATTEMPTS:-3' in block assert "cd_docker_push_attempt=${label}:${attempt}/${max_attempts}" in block + assert ( + 'if run_docker_step "${label}" "${timeout_seconds}" "$@"; then' + in block + ) + assert "rc=0\n else\n rc=$?" in block + assert ( + 'set +e\n run_docker_step "${label}" ' + '"${timeout_seconds}" "$@"' + not in block + ) assert "BLOCKER cd_docker_push_failed label=${label}" in block assert ( "NEXT_ACTION inspect_cd_runner_docker_build_push_or_registry_route_then_rerun_cd"