示例#1
0
if not clone_url:
    bot.Say("GOPHER_CUSTOM_REPOSITORY not set")
    exit()

if not cfgdir:
    bot.Say("GOPHER_CONFIGDIR not set")
    bot.Log("Error", "GOPHER_CONFIGDIR not set in updatecfg.py")
    exit()

if not bot.Exclusive("updatecfg", False):
    bot.Say("Configuration update already in progress")
    bot.Log("Warn", "Configuration update already in progress, exiting")
    exit()

bot.FailTask("status", [ "Updating configuration failed, check history for 'updatecfg'"])

if not clone_url.startswith("http"):
    match = re.match(r"ssh://(?:.*@)?([^:/]*)(?::([^/]*)/)?", clone_url)
    if match:
        bot.AddTask("ssh-init", [])
        scanhost = match.group(1)
        if match.group(2):
            scanhost = "%s:%s" % ( scanhost, match.group(2) )
        bot.AddTask("ssh-scan", [ scanhost ])
    else:
        match = re.match(r"(?:.*@)?([^:/]*)", clone_url)
        if match:
            bot.AddTask("ssh-init", [])
            bot.AddTask("ssh-scan", [ match.group(1) ])
示例#2
0
bot = Robot()

clone_url = os.getenv("GOPHER_CUSTOM_REPOSITORY")
clone_branch = os.getenv("GOPHER_CUSTOM_BRANCH")
cfgdir = os.getenv("GOPHER_CONFIGDIR")

if not clone_url:
    bot.Say("GOPHER_CUSTOM_REPOSITORY not set")
    exit()

if not cfgdir:
    bot.Say("GOPHER_CONFIGDIR not set")
    bot.Log("Error", "GOPHER_CONFIGDIR not set in updatecfg.py")
    exit()

if not bot.Exclusive("updatecfg", False):
    bot.Say("Configuration update already in progress")
    bot.Log("Warn", "Configuration update already in progress, exiting")
    exit()

bot.SetWorkingDirectory(cfgdir)
bot.FailTask("tail-log", [])
bot.FailTask("status", ["Updating configuration failed"])

bot.AddTask("git-init", [clone_url])
bot.AddTask("exec", ["git", "pull"])
bot.AddTask("run-pipeline", [])
bot.AddTask("status", ["Custom configuration repository successfully updated"])
bot.AddCommand("builtin-admin", "reload")