Skip to content

Commit

Permalink
Don't retrieve logs if a job gets cancelled
Browse files Browse the repository at this point in the history
Note that while it would look better to have an early return in the
`finally`, we can't do that as returning from `finally` eats the
exception and it doesn't get raised to the parent (which in this case
would be in charge of actually cancelling the build).

Skipping the log retrieval here is necessary because it would just wait
for the build to finish again, defeating the point of cancelling the
job.
  • Loading branch information
Eijebong committed Dec 18, 2024
1 parent 73aa390 commit 1812856
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions bitrisescript/src/bitrisescript/bitrise.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,19 @@ async def wait_and_download_workflow_log(artifacts_dir: str, build_slug: str) ->
artifacts_dir (str): Directory to download artifacts to.
build_slug (str): Identifier of workflow to run.
"""
skip_log_retrieval = False
try:
await wait_for_build_finish(build_slug)
log.info(f"Build '{build_slug}' is successful. Retrieving artifacts...")
await download_artifacts(build_slug, artifacts_dir)
except asyncio.CancelledError:
skip_log_retrieval = True
raise
finally:
log.info(f"Retrieving bitrise log for '{build_slug}'...")
await download_log(build_slug, artifacts_dir)
await dump_perfherder_data(artifacts_dir)
if not skip_log_retrieval:
log.info(f"Retrieving bitrise log for '{build_slug}'...")
await download_log(build_slug, artifacts_dir)
await dump_perfherder_data(artifacts_dir)


async def run_build(artifacts_dir: str, workflow_id: str, **build_params: Any) -> None:
Expand Down

0 comments on commit 1812856

Please sign in to comment.