def _getXMLForJob(self, data): kind = data.get('project-type', 'freestyle') for ep in pkg_resources.iter_entry_points( group='jenkins_jobs.projects', name=kind): Mod = ep.load() mod = Mod(self.registry) xml = mod.root_xml(data) self._gen_xml(xml, data) job = XmlJob(xml, data['name']) return job raise errors.JenkinsJobsException("Unrecognized project type: '%s'" % kind)
def _getXMLForView(self, data): kind = data.get('view-type', 'list') for ep in pkg_resources.iter_entry_points(group='jenkins_jobs.views', name=kind): Mod = ep.load() mod = Mod(self.registry) xml = mod.root_xml(data) self._gen_xml(xml, data) view = XmlJob(xml, data['name']) return view names = [ ep.name for ep in pkg_resources.iter_entry_points( group='jenkins_jobs.views') ] raise errors.JenkinsJobsException( 'Unrecognized view type: {} (supported types are: {})'.format( kind, ', '.join(names)))
def __init__(self, jenkins_url, flush=False): cache_dir = self.get_cache_dir() # One cache per remote Jenkins URL: host_vary = re.sub(r"[^A-Za-z0-9\-\~]", "_", jenkins_url) self.cachefilename = os.path.join( cache_dir, "cache-host-jobs-" + host_vary + ".yml") # generate named lockfile if none exists, and lock it self._locked = self._lock() if not self._locked: raise errors.JenkinsJobsException("Unable to lock cache for '%s'" % jenkins_url) if flush or not os.path.isfile(self.cachefilename): self.data = {} else: with io.open(self.cachefilename, "r", encoding="utf-8") as yfile: self.data = yaml.safe_load(yfile) logger.debug("Using cache: '{0}'".format(self.cachefilename))
def _getXMLForData(self, data): kind = data.get(self.kind_attribute, self.kind_default) for ep in pkg_resources.iter_entry_points( group=self.entry_point_group, name=kind): Mod = ep.load() mod = Mod(self.registry) xml = mod.root_xml(data) if "view-type" not in data: self._gen_xml(xml, data) obj = XmlJob(xml, data['name']) return obj names = [ ep.name for ep in pkg_resources.iter_entry_points( group=self.entry_point_group)] raise errors.JenkinsJobsException( 'Unrecognized {}: {} (supported types are: {})'.format( self.kind_attribute, kind, ', '.join(names)))