Skip to content

Commit 538eedc

Browse files
committed
CircleCI: Skip logs that return a 400 status when downloading
1 parent d389931 commit 538eedc

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/tinuous/circleci.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from typing import Any, List, Optional
1010

1111
from pydantic import BaseModel
12+
import requests
1213
from yaml import safe_load
1314

1415
from .base import APIClient
@@ -236,10 +237,20 @@ def download(self, path: Path) -> list[Path]:
236237
return []
237238
path.parent.mkdir(parents=True, exist_ok=True)
238239
log.info("Downloading logs for %s to %s", self.id, path)
239-
self.client.download(
240-
f"/v1.1/project/github/{self.repo}/{self.job}/output/{self.step}/{self.index}?file=true",
241-
path,
242-
)
240+
try:
241+
self.client.download(
242+
f"/v1.1/project/github/{self.repo}/{self.job}/output/{self.step}/{self.index}?file=true",
243+
path,
244+
)
245+
except requests.HTTPError as e:
246+
if e.response is not None and e.response.status_code == 404:
247+
# 404 can happen when a job was cancelled before it began.
248+
log.error(
249+
"Request for logs returned %d; skipping", e.response.status_code
250+
)
251+
return []
252+
else:
253+
raise
243254
return [path]
244255

245256

0 commit comments

Comments
 (0)