Skip to content

Commit

Permalink
Revision metadata is backwards compatible (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
ca-johnson authored Feb 25, 2020
1 parent dc3d47c commit f5ad213
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local_run: vendorize p4d
rm -f -r p4_workspace
mkdir local-pipeline -p
pushd local-pipeline && bk local run ../.buildkite/local-pipeline.yml --meta-data "buildkite-perforce-revision=6"
pushd local-pipeline && bk local run ../.buildkite/local-pipeline.yml --meta-data "buildkite-perforce-revision=@6"
$(MAKE) clean_p4d

test:
Expand Down
4 changes: 3 additions & 1 deletion python/buildkite.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
__LOCAL_RUN__ = os.environ['BUILDKITE_AGENT_NAME'] == 'local'

__REVISION_METADATA__ = 'buildkite-perforce-revision'
__REVISION_METADATA_DEPRECATED__ = 'buildkite:perforce:revision' # old metadata key, incompatible with `bk local run`
__SHELVED_METADATA__ = 'buildkite-perforce-shelved'
__SHELVED_ANNOTATION__ = "Saved shelved change {original} as {copy}"

Expand Down Expand Up @@ -96,7 +97,7 @@ def set_build_changelist(changelist):

def get_build_revision():
"""Get a p4 revision for the build from buildkite context"""
revision = get_metadata(__REVISION_METADATA__)
revision = get_metadata(__REVISION_METADATA__) or get_metadata(__REVISION_METADATA_DEPRECATED__)
if revision:
return revision

Expand All @@ -115,6 +116,7 @@ def get_build_revision():
def set_build_revision(revision):
"""Set the p4 revision for following jobs in this build"""
set_metadata(__REVISION_METADATA__, revision)
set_metadata(__REVISION_METADATA_DEPRECATED__, revision)

def set_build_info(revision, description):
"""Set the description and commit number in the UI for this build by mimicking a git repo"""
Expand Down

0 comments on commit f5ad213

Please sign in to comment.