def copy(self): yield self.runRmdir(self.workdir, abandonOnFailure=False, timeout=self.timeout) old_workdir = self.workdir self.workdir = self.srcdir try: yield self.mode_incremental() cmd = buildstep.RemoteCommand( 'cpdir', { 'fromdir': self.srcdir, 'todir': old_workdir, 'logEnviron': self.logEnviron, 'timeout': self.timeout, }) cmd.useLog(self.stdio_log, False) yield self.runCommand(cmd) if cmd.didFail(): raise buildstep.BuildStepFailed() return RC_SUCCESS finally: self.workdir = old_workdir
def _sourcedirIsUpdatable(self): # first, perform a stat to ensure that this is really an svn directory res = yield self.pathExists(self.build.path_module.join(self.workdir, '.svn')) if not res: return False # then run 'svn info --xml' to check that the URL matches our repourl stdout, stderr = yield self._dovccmd(['info', '--xml'], collectStdout=True, collectStderr=True, abandonOnFailure=False) # svn: E155037: Previous operation has not finished; run 'cleanup' if # it was interrupted if 'E155037:' in stderr: return False try: stdout_xml = xml.dom.minidom.parseString(stdout) extractedurl = stdout_xml.getElementsByTagName( 'url')[0].firstChild.nodeValue except xml.parsers.expat.ExpatError: msg = "Corrupted xml, aborting step" self.stdio_log.addHeader(msg) raise buildstep.BuildStepFailed() return extractedurl == self.svnUriCanonicalize(self.repourl)
def commandComplete(cmd): if abandonOnFailure and cmd.didFail(): raise buildstep.BuildStepFailed() return evaluateCommand(cmd)
def evaluateCommand(_): if cmd.didFail(): raise buildstep.BuildStepFailed() return cmd.rc
def evaluateCommand(rc): if rc != 0: log.msg("Failed removing files") raise buildstep.BuildStepFailed() return rc
def evaluateCommand(_): if cmd.rc != 0 and abandonOnFailure: log.msg( "Source step failed while running command {}".format(cmd)) raise buildstep.BuildStepFailed() return cmd.rc
def evaluate(cmd): if cmd.didFail(): raise buildstep.BuildStepFailed() return cmd.rc
def checkInstall(svnInstalled): if not svnInstalled: raise buildstep.BuildStepFailed("SVN is not installed on slave") return 0
def evaluateCommand(cmd): if cmd.rc != 0: log.msg("Source step failed while running command %s" % cmd) raise buildstep.BuildStepFailed() return cmd.rc
def _dovccmd(self, command, abandonOnFailure=True, collectStdout=False, initialStdin=None): full_command = ['git'] full_env = self.env.copy() if self.env else {} if self.config is not None: for name, value in iteritems(self.config): full_command.append('-c') full_command.append('%s=%s' % (name, value)) if self._isSshPrivateKeyNeededForGitCommand(command): self._adjustCommandParamsForSshPrivateKey(full_command, full_env) full_command.extend(command) # check for the interruptSignal flag sigtermTime = None interruptSignal = None # If possible prefer to send a SIGTERM to git before we send a SIGKILL. # If we send a SIGKILL, git is prone to leaving around stale lockfiles. # By priming it with a SIGTERM first we can ensure that it has a chance to shut-down gracefully # before getting terminated if not self.workerVersionIsOlderThan("shell", "2.16"): # git should shut-down quickly on SIGTERM. If it doesn't don't let it # stick around for too long because this is on top of any timeout # we have hit. sigtermTime = 1 else: # Since sigtermTime is unavailable try to just use SIGTERM by itself instead of # killing. This should be safe. if self.workerVersionIsOlderThan("shell", "2.15"): log.msg( "NOTE: worker does not allow master to specify " "interruptSignal. This may leave a stale lockfile around " "if the command is interrupted/times out\n") else: interruptSignal = 'TERM' cmd = remotecommand.RemoteShellCommand(self.workdir, full_command, env=full_env, logEnviron=self.logEnviron, timeout=self.timeout, sigtermTime=sigtermTime, interruptSignal=interruptSignal, collectStdout=collectStdout, initialStdin=initialStdin) cmd.useLog(self.stdio_log, False) yield self.runCommand(cmd) if abandonOnFailure and cmd.didFail(): log.msg("Source step failed while running command %s" % cmd) raise buildstep.BuildStepFailed() if collectStdout: defer.returnValue(cmd.stdout) return defer.returnValue(cmd.rc)
def evaluate(rc): if rc != 0: raise buildstep.BuildStepFailed() return rc
def evaluateCommand(_): if abandonOnFailure and cmd.didFail(): self.descriptionDone = "repo failed at: %s" % (" ".join(command[:2])) self.stdio_log.addStderr("Source step failed while running command %s\n" % cmd) raise buildstep.BuildStepFailed() return cmd.rc
def evaluateCommand(cmd): if abandonOnFailure and cmd.didFail(): self.step_status.setText(["repo failed at: %s" % (" ".join(command[:2]))]) self.stdio_log.addStderr("Source step failed while running command %s\n" % cmd) raise buildstep.BuildStepFailed() return cmd.rc
def checkUpdated(cmd): if cmd.didFail() and self.checkExpectedFailure(cmd, errors): log.msg("Source step failed while running command %s" % cmd) raise buildstep.BuildStepFailed() return cmd.rc
def checkPull(cmd): if cmd.didFail() and self.checkExpectedFailure(cmd, errors): raise buildstep.BuildStepFailed() return cmd.rc