Skip to content

Commit

Permalink
Allow switching off shelve cl backups via plugin config (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
ca-johnson authored Jul 30, 2019
1 parent 69f1251 commit a7920e9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .buildkite/local-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ steps:
p4user: banana
view: //depot/... ...
root: p4_workspace
parallel: 2
parallel: 2
backup_changelists: yes
4 changes: 3 additions & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ configuration:
parallel:
type: string
client_opts:
type: string
type: string
backup_changelists:
type: bool
3 changes: 3 additions & 0 deletions python/buildkite.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def get_config():
conf['view'] = ['%s %s' % (v, next(view_iter)) for v in view_iter]
return conf

def should_backup_changelists():
return os.environ.get('BUILDKITE_PLUGIN_PERFORCE_BACKUP_CHANGELISTS', 'false') == 'true'

def get_metadata(key):
"""If it exists, retrieve metadata from buildkite for a given key"""
if not __ACCESS_TOKEN__ or __LOCAL_RUN__:
Expand Down
9 changes: 6 additions & 3 deletions python/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

from perforce import P4Repo
from buildkite import (get_env, get_config, get_build_revision, set_build_revision,
get_users_changelist, get_build_changelist, set_build_changelist, set_build_info)
get_users_changelist, get_build_changelist, set_build_changelist, set_build_info,
should_backup_changelists)

def main():
"""Main"""
Expand All @@ -25,7 +26,7 @@ def main():

# Convert changelist number to revision specifier
if re.match(r'^\d*$', revision):
revision = '@%d' % revision
revision = '@%s' % revision

repo.sync(revision=revision)

Expand All @@ -37,7 +38,9 @@ def main():
# Use existing or make a copy of the users changelist for this build
changelist = get_build_changelist()
if not changelist:
changelist = repo.backup(user_changelist)
changelist = user_changelist
if should_backup_changelists():
changelist = repo.backup(user_changelist)
set_build_changelist(changelist)

repo.unshelve(changelist)
Expand Down

0 comments on commit a7920e9

Please sign in to comment.