Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 529bfb4

Browse files
committed
Ignore errors loading artifacts from CircleCI
Previously, this seemed to be ignored, and we'd just get a 0-artifact count. But now it seems that requesting artifacts for builds that are incomplete raises a 400 Bad Request. So ignore those errors and return a 0-length artifact, because that is already correctly handled by the next step in the workflow.
1 parent 78bf53c commit 529bfb4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

.circleci/fetch_doc_logs.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from pathlib import Path
2323
import sys
2424
from urllib.parse import urlparse
25-
from urllib.request import urlopen
25+
from urllib.request import URLError, urlopen
2626

2727

2828
if len(sys.argv) != 2:
@@ -38,8 +38,11 @@
3838
f'{organization}/{repository}/{build_id}/artifacts'
3939
)
4040
print(artifact_url)
41-
with urlopen(artifact_url) as response:
42-
artifacts = json.load(response)
41+
try:
42+
with urlopen(artifact_url) as response:
43+
artifacts = json.load(response)
44+
except URLError:
45+
artifacts = {'items': []}
4346
artifact_count = len(artifacts['items'])
4447
print(f'Found {artifact_count} artifacts')
4548

0 commit comments

Comments
 (0)