From: Thibaut VARÈNE Date: Fri, 22 Jun 2018 10:16:36 +0000 (+0200) Subject: phase1: use do_cleanup to select Git() method X-Git-Tag: v1~142 X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=1bd3c0f2c175713ff5e26605790c9f9e04219701;p=buildbot.git phase1: use do_cleanup to select Git() method Git() parameters cannot accept a renderer such as Interpolate() (this feature is only available from buildbot version 0.8.10). To implement this feature in 0.8.9 we have to split the 'fresh' and 'clean' cases and make them separate steps that are mutually exclusive (via doStepIf). Signed-off-by: Thibaut VARÈNE --- diff --git a/phase1/master.cfg b/phase1/master.cfg index a4e21da..4132f27 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -237,6 +237,16 @@ def IsCleanupRequested(step): def IsExpireRequested(step): return not IsCleanupRequested(step) +def IsGitFreshRequested(step): + do_cleanup = step.getProperty("do_cleanup") + if do_cleanup: + return True + else: + return False + +def IsGitCleanRequested(step): + return not IsGitFreshRequested(step) + def IsTaggingRequested(step): val = step.getProperty("tag") if val and re.match("^[0-9]+\.[0-9]+\.[0-9]+(?:-rc[0-9]+)?$", val): @@ -508,6 +518,8 @@ for target in targets: # if repo doesn't exist: 'git clone repourl' # method 'clean' runs 'git clean -d -f', method fresh runs 'git clean -d -f x'. Only works with mode='full' # 'git fetch -t repourl branch; git reset --hard revision' + # Git() parameters can't take a renderer until buildbot 0.8.10, so we have to split the fresh and clean cases + # if buildbot is updated, one can use: method = Interpolate('%(prop:do_cleanup:#?|fresh|clean)s') factory.addStep(Git( repourl = repo_url, branch = repo_branch, @@ -515,6 +527,17 @@ for target in targets: method = 'clean', locks = NetLockDl, haltOnFailure = True, + doStepIf = IsGitCleanRequested, + )) + + factory.addStep(Git( + repourl = repo_url, + branch = repo_branch, + mode = 'full', + method = 'fresh', + locks = NetLockDl, + haltOnFailure = True, + doStepIf = IsGitFreshRequested, )) # update remote refs