@@ -8,7 +8,7 @@ import requests
88
99_API_TOKEN = os .environ ["BUILDKITE_API_TOKEN" ]
1010_BASE_URL = "https://api.buildkite.com/v2/organizations/"
11- _BUILDKITE_AUTH_HEADERS = {"Authorization" : f"Bearer { _API_TOKEN } " }
11+ _BUILDKITE_AUTH_HEADERS = {"Authorization" : f"Bearer { _API_TOKEN } " , "Content-Type" : "application/json" }
1212
1313ansi_escape_8bit = re .compile (
1414 r"(?:\x1B[@-Z\\-_]|[\x80-\x9A\x9C-\x9F]|(?:\x1B\[|\x9B)[0-?]*[ -/]*[@-~])"
@@ -27,12 +27,9 @@ def _build_parser() -> argparse.ArgumentParser:
2727
2828
2929def _get_job_log (
30- org : str , pipeline : str , build_number : str , job_id : str
30+ job_url : str
3131) -> str :
32- response = requests .get (
33- f"{ _BASE_URL } /{ org } /pipelines/{ pipeline } /builds/{ build_number } /jobs/{ job_id } /log" ,
34- headers = _BUILDKITE_AUTH_HEADERS ,
35- )
32+ response = requests .get (job_url , headers = _BUILDKITE_AUTH_HEADERS )
3633 response .raise_for_status ()
3734 return ansi_escape_8bit .sub ("" , response .json ()["content" ]).replace (
3835 "\r " , ""
@@ -52,12 +49,8 @@ async def _main(org: str, pipeline: str, build_number: str) -> None:
5249 futures = []
5350
5451 for job in build ["jobs" ]:
55- job_id = str (job ["id" ])
56- futures .append (
57- loop .run_in_executor (
58- None , _get_job_log , org , pipeline , build_number , job_id
59- )
60- )
52+ log_url = str (job ["log_url" ])
53+ futures .append (loop .run_in_executor (None , _get_job_log , log_url ))
6154
6255 for future in futures :
6356 combined_log += await future
0 commit comments