# in a git repository specified in the GOPHER_CUSTOM_REPOSITORY # environment variable, which translates to CUSTOM_REPOSITORY_URL # in the job (see the definition for the updatecfg job in # conf/gopherbot.yaml). When this job is run, the robot will attempt # to clone or pull it's configuration repository. # Note that if your config repo has a '.gopherci/pipeline.sh', it'll # get executed - useful for e.g. installing $HOME/.ssh/config. import os import re import sys sys.path.append("%s/lib" % os.getenv("GOPHER_INSTALLDIR")) from gopherbot_v1 import Robot bot = Robot() clone_url = os.getenv("CUSTOM_REPOSITORY_URL") clone_branch = os.getenv("CUSTOM_REPOSITORY_BRANCH") if not clone_url: bot.Say("GOPHER_CUSTOM_REPOSITORY not set") 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'"])
#!/usr/bin/python import os import sys sys.path.append("%s/lib" % os.getenv("GOPHER_INSTALLDIR")) from gopherbot_v1 import Robot bot = Robot() default_config = ''' --- Help: - Keywords: [ "python" ] Helptext: [ "(bot), python (me!) - prove that python plugins work" ] - Keywords: [ "listen" ] Helptext: [ "(bot), listen (to me!) - ask a question" ] - Keywords: [ "remember", "memory" ] Helptext: [ "(bot), remember <anything> - prove the robot has a brain(tm)" ] - Keywords: [ "recall", "memory" ] Helptext: [ "(bot), recall - prove the robot has a brain(tm)" ] - Keywords: [ "forget", "memory" ] Helptext: [ "(bot), forget <#> - ask the robot to forget one of it's remembered 'facts'" ] - Keywords: [ "check" ] Helptext: [ "(bot), check me - get the bot to check you out" ] CommandMatchers: - Regex: (?i:python( me)?!?) Command: python - Regex: (?i:listen( to me)?!?) Command: listen - Regex: (?i:remember ([-\w .,!?:\/]+)) Command: remember
#!/usr/bin/python import os import sys sys.path.append("%s/lib" % os.getenv("GOPHER_INSTALLDIR")) from gopherbot_v1 import Robot bot = Robot() default_config = ''' Channels: - random AllowDirect: false Help: - Keywords: [ "format", "world" ] Helptext: [ "(bot), format world - exercise formatting options" ] CommandMatchers: - Regex: '(?i:format world)' Command: "format" ''' executable = sys.argv.pop(0) command = sys.argv.pop(0) if command == "configure": print(default_config) if command == "format": bot = bot.MessageFormat("Variable") proto = bot.GetBotAttribute("protocol")
# called with two arguments, they are interpreted as the repository and branch # of a primary build. When called with four arguments, the first two are the # repository and branch to build, and the second two are the repository and # branch that triggered the build. # # The build type is responsible for calling Exclusive, setting up the build # directory, and adding the initial pipeline tasks. All other # pipeline/dependency logic is in gopherci. import os import re import sys sys.path.append("%s/lib" % os.getenv("GOPHER_INSTALLDIR")) from gopherbot_v1 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_REPO", repository) 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)
#!/usr/bin/python import os import sys sys.path.append("%s/lib" % os.getenv("GOPHER_INSTALLDIR")) from gopherbot_v1 import Robot bot = Robot() executable = sys.argv.pop(0) command = sys.argv.pop(0) if command == "configure": exit(0) repodata = bot.GetRepoData() def start_build(repository, branch): bot.Say("Ok, I'll start the gopherci job for %s, %s branch..." % (repository, branch)) bot.AddJob("gopherci", [ repository, branch ]) if not isinstance(repodata, dict): bot.Say("'repodata.yaml' missing or invalid; GetRepoData() failed") exit(0) if command == "build": build = [] repospec = sys.argv.pop(0).lower() fcount = len(repospec.split("/")) branch = sys.argv.pop(0)