def t07(): pretty = '%s t7' % __file__ print(pretty) w = Workspace() w.config['jenkins'] = JENKINS; job = JenkinsJob(w.config['jenkins'], JOB_ID) try: job.load() build = job.last_successful() except Exception, e: print('FAIL %s: got exception: %s' % (pretty, str(e))) w.delete() return
def t18(): pretty = '%s t18' % __file__ print(pretty) w = Workspace() job = JenkinsJob(base=JENKINS_WITH_BUILD_PARAMETERS, job=JOB_ID_WITH_BUILD_PARAMETERS) try: job.load() build = job.last_successful() build_parameters = build.build_parameters product = build_parameters['PRODUCT'] except Exception, e: print('FAIL %s: got exception: %s' % (pretty, str(e))) w.delete() return
def t17(): pretty = '%s t17' % __file__ print(pretty) w = Workspace() exc = None try: job = JenkinsJob(base=JENKINS_WITH_BUILD_PARAMETERS, job=JOB_ID_WITH_BUILD_PARAMETERS) build = job.last_successful() build_parameters = build.load_build_parameters(timeout=0.000001) print('FAIL %s: JenkinsBuild.load_build_parameters() did not time ' 'out' % pretty) w.delete() return except Exception, e: exc = e
def download_jenkins(self, job_id, build_id=None, artifacts=None, dst=None, timeout=0, base=None): if not base: if 'jenkins' in self.config: base = self.config['jenkins'] else: raise Exception('jenkins base URL is not set or provided') if build_id: build = JenkinsBuild(base, job_id, build_id, home=self.home) path = os.path.join(self.path, 'jenkins', job_id, build_id) else: job = JenkinsJob(base, job_id, home=self.home) build = job.last_successful(timeout) path = os.path.join(self.path, 'jenkins', job_id, str(build.build)) if dst: # check that destination is within self.root.uid if dst.startswith('/'): dst = os.path.normpath(dst) if not dst.startswith(self.path): raise Exception('destination can not be outside workspace') path = os.path.join(self.path, dst) # override default path build.download(path, artifacts, timeout) if (not build_id) and (not dst): # only create the last_completed indicator when downloading to a # to default directory. where would we put it when the user has # made an explicit choice about the directory structure? would it # even be helpful to have the indicator? last = os.path.join(self.path, 'jenkins', job_id, 'last_successful') # symlink would be nicer, but this works on windows too: f = open(last, 'w') f.write(str(build.build)) f.close() return path