Skip to content

Commit 51a554d

Browse files
committed
Add commit_sha in logger
1 parent c8945e9 commit 51a554d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

scripts/release/build/build_scenario.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from git import Repo
44

55
from lib.base_logger import logger
6-
from scripts.release.constants import triggered_by_git_tag, is_evg_patch, is_running_in_evg, get_version_id
6+
from scripts.release.constants import triggered_by_git_tag, is_evg_patch, is_running_in_evg, get_version_id, \
7+
get_github_commit
78
from scripts.release.version import calculate_next_version
89

910
COMMIT_SHA_LENGTH = 8
@@ -22,6 +23,7 @@ def infer_scenario_from_environment(cls) -> "BuildScenario":
2223
is_patch = is_evg_patch()
2324
is_evg = is_running_in_evg()
2425
patch_id = get_version_id()
26+
commit_sha = get_github_commit()
2527

2628
if git_tag:
2729
# Release scenario and the git tag will be used for promotion process only
@@ -32,7 +34,7 @@ def infer_scenario_from_environment(cls) -> "BuildScenario":
3234
logger.info(f"Build scenario: {scenario} (patch_id: {patch_id})")
3335
elif is_evg:
3436
scenario = BuildScenario.STAGING
35-
logger.info(f"Build scenario: {scenario} (patch_id: {patch_id})")
37+
logger.info(f"Build scenario: {scenario} (commit_sha: {commit_sha[:COMMIT_SHA_LENGTH]})")
3638
else:
3739
scenario = BuildScenario.DEVELOPMENT
3840
logger.info(f"Build scenario: {scenario}")

scripts/release/constants.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,12 @@ def get_version_id() -> str | None:
5151
:return: version_id (patch ID) or None if not set
5252
"""
5353
return os.getenv("version_id")
54+
55+
56+
def get_github_commit() -> str | None:
57+
"""
58+
${github_commit} is the commit hash of the commit that triggered the patch run.
59+
For non pull-request patches, it will be the same as ${revision}.
60+
:return: github_commit or None if not set
61+
"""
62+
return os.getenv("github_commit")

0 commit comments

Comments
 (0)