bazelci.py: Add back fetch_buildkite_token function
* Add back fetch_buildkite_token function
broke because we need to access buildkite API to get the status of the jobs in order to rerun the failed ones.
* Add comment
@@ -545,6 +545,7 @@ def tests_with_status(bep_file, status):
__saucelabs_token__ = None
+__buildkite_token__ = None
def fetch_saucelabs_token():
@@ -587,6 +588,47 @@ def fetch_saucelabs_token():
os.remove("saucelabs-access-key.enc")
+def fetch_buildkite_token():
+ """This function is used in buildkite/incompatible_flag_verbose_failures.py"""
+ global __buildkite_token__
+ if __buildkite_token__:
+ return __buildkite_token__
+ try:
+ execute_command(
+ [
+ gsutil_command(),
+ "cp",
+ "gs://bazel-encrypted-secrets/buildkite-api-token.enc",
+ "buildkite-api-token.enc",
+ ]
+ )
+ __buildkite_token__ = (
+ subprocess.check_output(
+ [
+ gcloud_command(),
+ "kms",
+ "decrypt",
+ "--location",
+ "global",
+ "--keyring",
+ "buildkite",
+ "--key",
+ "buildkite-api-token",
+ "--ciphertext-file",
+ "buildkite-api-token.enc",
+ "--plaintext-file",
+ "-",
+ ],
+ env=os.environ,
+ )
+ .decode("utf-8")
+ .strip()
+ )
+ return __buildkite_token__
+ finally:
+ os.remove("buildkite-api-token.enc")
+
+
def is_pull_request():
third_party_repo = os.getenv("BUILDKITE_PULL_REQUEST_REPO", "")
return len(third_party_repo) > 0
