1
0
Fork 0

set build info in metadata

This commit is contained in:
Mikhail Goncharov 2021-05-03 21:07:00 +02:00
parent 980db3f06f
commit 6b731dc4d5
3 changed files with 15 additions and 2 deletions

View file

@ -31,6 +31,12 @@ def upload_file(base_dir: str, file: str):
return None
def set_metadata(key: str, value: str):
r = subprocess.run(f'buildkite-agent meta-data set "{key}" "{value}"', shell=True, capture_output=True)
if r.returncode != 0:
logging.warning(r)
def annotate(message: str, style: str = 'default', context: Optional[str] = None, append: bool = True):
"""
Adds an annotation for that currently running build.

View file

@ -15,6 +15,7 @@
import os
import yaml
from buildkite_utils import annotate, feedback_url, set_metadata
if __name__ == '__main__':
diff_id = os.getenv("ph_buildable_diff")
@ -22,6 +23,10 @@ if __name__ == '__main__':
base_commit = os.getenv('ph_base_commit', 'auto')
run_build = os.getenv('ph_skip_build') is None
trigger = os.getenv('ph_trigger_pipeline')
set_metadata('ph_buildable_diff', os.getenv("ph_buildable_diff"))
set_metadata('ph_buildable_revision', os.getenv('ph_buildable_revision'))
set_metadata('ph_build_id', os.getenv("ph_build_id"))
if trigger is None:
trigger = 'premerge-checks'

View file

@ -16,7 +16,7 @@
import logging
import os
from buildkite_utils import annotate, feedback_url
from buildkite_utils import annotate, feedback_url, set_metadata
from choose_projects import ChooseProjects
import git
from steps import generic_linux, generic_windows, from_shell_output, checkout_scripts
@ -39,7 +39,9 @@ if __name__ == '__main__':
annotate(f"Build for [D{os.getenv('ph_buildable_revision')}#{diff_id}]({url}). "
f"[Harbormaster build](https://reviews.llvm.org/harbormaster/build/{os.getenv('ph_build_id')}).\n"
f"If there is a build infrastructure issue, please [create a bug]({feedback_url()}).")
set_metadata('ph_buildable_diff', os.getenv("ph_buildable_diff"))
set_metadata('ph_buildable_revision', os.getenv('ph_buildable_revision'))
set_metadata('ph_build_id', os.getenv("ph_build_id"))
# List all affected projects.
repo = git.Repo('.')
patch = repo.git.diff("HEAD~1")