示例#1
0
sys.path.append("%s/lib" % os.getenv("GOPHER_INSTALLDIR"))
from gopherbot_v2 import Robot

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.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):
示例#2
0
# Usage: AddTask git-init <clone_url>

import os
import re
import sys
sys.path.append("%s/lib" % os.getenv("GOPHER_INSTALLDIR"))
from gopherbot_v2 import Robot

bot = Robot()

cfgdir = os.getenv("GOPHER_CONFIGDIR")
try:
    os.stat("%s/git/config" % cfgdir)
except FileNotFoundError:
    bot.Log("Warn", "%s/git/config not found, git push will fail" % cfgdir)

bot.SetParameter("XDG_CONFIG_HOME", cfgdir)

# Pop off the executable path
sys.argv.pop(0)

clone_url = sys.argv.pop(0)

if not clone_url.startswith("http"):
    match = re.match(r"ssh://(?:.*@)?([^:/]*)(?::([^/]*)/)?", clone_url)
    if match:
        scanhost = match.group(1)
        if match.group(2):
            scanhost = "%s:%s" % (scanhost, match.group(2))
    else:
示例#3
0
    repoconf = repodata[repository]

if "CloneURL" not in repoconf:
    bot.Say("No 'clone_url' specified for '%s' in repositories.yaml" %
            repository)
    exit()
clone_url = repoconf["CloneURL"]

if "KeepHistory" not in repoconf:
    keep_history = 7
else:
    keep_history = repoconf["KeepHistory"]

repobranch = "%s/%s" % (repository, branch)
if not bot.Exclusive(repobranch, False):
    bot.Log("Warn", "Build of '%s' already in progress, exiting" % repobranch)
    if len(bot.user) > 0:
        bot.Say(
            "localbuild of '%s' already in progress, not starting a new build"
            % repobranch)
    exit()

bot.ExtendNamespace(repobranch, keep_history)

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))
示例#4
0
# Pop off the executable path
sys.argv.pop(0)

command = sys.argv.pop(0)
if command != "init":
    exit(0)

cfgdir = os.getenv("GOPHER_CONFIGDIR")
cfgfile = os.path.join(cfgdir, "conf", "gopherbot.yaml")

try:
    os.stat(cfgfile)
except FileNotFoundError:
    pass
except:
    bot.Log("Error", "Checking for gopherbot.yaml: %s" % sys.exc_info()[0])
    exit(1)
else:
    exit(0)

clone_url = os.getenv("GOPHER_CUSTOM_REPOSITORY")
if len(clone_url) == 0:
    bot.Log("Warn", "GOPHER_CUSTOM_REPOSITORY not set, not bootstrapping")
    exit(0)

bot.Log("Info", "Creating bootstrap pipeline for %s" % clone_url)

ssh_repo = False
if not clone_url.startswith("http"):
    match = re.match(r"ssh://(?:.*@)?([^:/]*)(?::([^/]*)/)?", clone_url)
    if match:
示例#5
0
sys.argv.pop(0)

command = sys.argv.pop(0)
if command != "init":
    exit(0)

cfgdir = os.getenv("GOPHER_CONFIGDIR")
cfgconf = os.path.join(cfgdir, "conf")

hasconfig = True
try:
    os.stat(cfgconf)
except FileNotFoundError:
    hasconfig = False
except:
    bot.Log("Error", "Checking for %s: %s" % (cfgconf, sys.exc_info()[0]))
    exit(1)

# First, see if we're doing a restore
if hasconfig:
    try:
        os.stat(".restore")
        bot.AddTask("exec", [ "rm", "-f", ".restore" ])
        bot.AddJob("restore", [])
        exit(0)
    except FileNotFoundError:
        pass
    exit(0)

clone_url = os.getenv("GOPHER_CUSTOM_REPOSITORY")
if len(clone_url) == 0:
示例#6
0
#
# NOTE: current gopherci does not cascade dependent builds; if a dependency
# build is itself a de

import os
import sys
sys.path.append("%s/lib" % os.getenv("GOPHER_INSTALLDIR"))
from gopherbot_v2 import Robot

bot = Robot()

repodata = bot.GetRepoData()

if not isinstance(repodata, dict):
    bot.Log(
        "Warn",
        "GopherCI triggered with invalid 'repositories.yaml', not a python 'dict'"
    )
    exit(0)

build_triggered = False

# Pop off the executable path
sys.argv.pop(0)

repository = sys.argv.pop(0)
branch = sys.argv.pop(0)
if branch.endswith("/"):  # illegal end char; assume args swapped
    repository, branch = branch, repository

if repository.endswith("/"):
    repository = repository.rstrip("/")