Esempio n. 1
0
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:
        match = re.match(r"(?:.*@)?([^:/]*)", clone_url)
        if match:
Esempio n. 2
0
# pipeline/dependency logic is in gopherci.

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

bot = Robot()

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

repository = sys.argv.pop(0)
branch = sys.argv.pop(0)
bot.SetParameter("GOPHERCI_BRANCH", branch)
if len(sys.argv) > 0:
    deprepo = sys.argv.pop(0)
    depbranch = sys.argv.pop(0)
    bot.SetParameter("GOPHERCI_DEPBUILD", "true")
    bot.SetParameter("GOPHERCI_DEPREPO", deprepo)
    bot.SetParameter("GOPHERCI_DEPBRANCH", depbranch)

repodata = bot.GetRepoData()

if repository in repodata:
    repoconf = repodata[repository]

if "CloneURL" not in repoconf:
    bot.Say("No 'clone_url' specified for '%s' in repositories.yaml" %
            repository)
Esempio n. 3
0
        bot.AddJob("restore", [])
        exit(0)
    except FileNotFoundError:
        pass
    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)

clone_branch = os.getenv("GOPHER_CUSTOM_BRANCH")

if not clone_url.startswith("http"):
    depkey = os.getenv("GOPHER_DEPLOY_KEY")
    if len(depkey) == 0:
        bot.Log("Error", "SSH required for bootstrapping and no GOPHER_DEPLOY_KEY set")
        exit(1)

bot.Log("Info", "Creating bootstrap pipeline for %s" % clone_url)
bot.SetParameter("BOOTSTRAP", "true")
bot.SetParameter("GOPHER_DEPLOY_KEY", depkey)
bot.AddTask("git-init", [ clone_url ])

tkey = os.path.join(cfgdir, "binary-encrypted-key")
bot.AddTask("exec", [ "rm", "-f", tkey ])
bot.AddTask("exec", [ "touch", ".restore" ])
bot.AddTask("git-clone", [ clone_url, clone_branch, cfgdir, "true" ])
bot.AddTask("run-pipeline", [])
bot.AddTask("restart-robot", [])
Esempio n. 4
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:
        ssh_repo = True
        scanhost = match.group(1)
        if match.group(2):
            scanhost = "%s:%s" % ( scanhost, match.group(2) )
    else:
        match = re.match(r"(?:.*@)?([^:/]*)", clone_url)
        if match:
            ssh_repo = True
            scanhost = match.group(1)

if ssh_repo:
    depkey = os.getenv("DEPLOY_KEY")
    if len(depkey) == 0:
        bot.Log("Error", "GOPHER_CUSTOM_REPOSITORY needs ssh, but no DEPLOY_KEY set")
        exit(1)
    bot.SetParameter("DEPLOY_KEY", depkey)
    bot.AddTask("ssh-init", ["bootstrap"])
    bot.AddTask("ssh-scan", [ scanhost ])

tkey = os.path.join(cfgdir, "binary-encrypted-key")
bot.AddTask("exec", [ "rm", "-f", tkey ])
bot.AddTask("git-sync", [ clone_url, "master", cfgdir, "false" ])
bot.AddTask("exec", [ "touch", ".restore" ])
bot.AddTask("restart", [])
Esempio n. 5
0
from gopherbot_v2 import Robot

bot = Robot()

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

# localbuild and all build types always get a "command" from gopherci,
# never triggered.
# One of "build", "depbuild", "job"
command = sys.argv.pop(0)

repository = sys.argv.pop(0)
branch = sys.argv.pop(0)

bot.SetParameter("GOPHERCI_BRANCH", branch)
pipeline = "pipeline"

if command == "job":
    pipeline = sys.argv.pop(0)
    bot.SetParameter("GOPHERCI_CUSTOM_PIPELINE", pipeline)

if command == "depbuild":
    deprepo = sys.argv.pop(0)
    depbranch = sys.argv.pop(0)
    bot.SetParameter("GOPHERCI_DEPBUILD", "true")
    bot.SetParameter("GOPHERCI_DEPREPO", deprepo)
    bot.SetParameter("GOPHERCI_DEPBRANCH", depbranch)

repodata = bot.GetRepoData()