Bugfix and tidy-up
Allow the configuration file to be optional for test mode Tidy-up the hipchat notifier module - Require a valid hipchat authtoken Ignore temporary vi/vim files in .gitignore Add extra debugging output - write out cache file to enable easy removal to force upload - clearly notify that no changes are seen so uploading not occurring Change-Id: Ia418704b76090e284e0b801609f2f05bfa06b9ae Reviewed-on: https://review.openstack.org/20380 Reviewed-by: Jeremy Stanley <fungi@yuggoth.org> Reviewed-by: Khai Do <do.khai@gmail.com> Reviewed-by: Clark Boylan <clark.boylan@gmail.com> Approved: James E. Blair <corvus@inaugust.com> Reviewed-by: James E. Blair <corvus@inaugust.com> Tested-by: Jenkins
This commit is contained in:
parent
fcb82e93ea
commit
efa1ddf0c3
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.*.swp
|
||||
*.egg
|
||||
*.egg-info
|
||||
*.pyc
|
||||
|
@ -237,6 +237,7 @@ class CacheStorage(object):
|
||||
self.data = {}
|
||||
return
|
||||
self.data = yaml.load(yfile)
|
||||
logger.debug("Using cache: '{0}'".format(self.cachefilename))
|
||||
yfile.close()
|
||||
|
||||
@staticmethod
|
||||
@ -348,3 +349,5 @@ class Builder(object):
|
||||
if self.cache.has_changed(job.name, md5):
|
||||
self.jenkins.update_job(job.name, job.output())
|
||||
self.cache.set(job.name, md5)
|
||||
else:
|
||||
logger.debug("'{0}' has not changed".format(job.name))
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import jenkins_jobs.builder
|
||||
import jenkins_jobs.errors
|
||||
import argparse
|
||||
import ConfigParser
|
||||
import logging
|
||||
@ -52,13 +53,18 @@ def main():
|
||||
if os.path.isfile(localconf):
|
||||
conf = localconf
|
||||
|
||||
if not options.command == 'test':
|
||||
if os.path.isfile(conf):
|
||||
logger.debug("Reading config from {0}".format(conf))
|
||||
conffp = open(conf, 'r')
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.readfp(conffp)
|
||||
else:
|
||||
elif options.command == 'test':
|
||||
logger.debug("Not reading config for test output generation")
|
||||
config = {}
|
||||
else:
|
||||
raise jenkins_jobs.errors.JenkinsJobsException(
|
||||
"A valid configuration file is required when not run as a test")
|
||||
|
||||
logger.debug("Config: {0}".format(config))
|
||||
builder = jenkins_jobs.builder.Builder(config.get('jenkins', 'url'),
|
||||
config.get('jenkins', 'user'),
|
||||
|
@ -47,6 +47,7 @@ import jenkins_jobs.modules.base
|
||||
import jenkins_jobs.errors
|
||||
import logging
|
||||
import ConfigParser
|
||||
import sys
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -65,15 +66,18 @@ class HipChat(jenkins_jobs.modules.base.Base):
|
||||
unless actually required.
|
||||
"""
|
||||
if(not self.authToken):
|
||||
# Verify that the config object in the registry is of type
|
||||
# ConfigParser (it could possibly be a regular 'dict' object which
|
||||
# doesn't have the right get() method).
|
||||
if(not isinstance(self.registry.global_config,
|
||||
ConfigParser.ConfigParser)):
|
||||
raise jenkins_jobs.errors.JenkinsJobsException(
|
||||
'HipChat requires a config object in the registry.')
|
||||
self.authToken = self.registry.global_config.get(
|
||||
'hipchat', 'authtoken')
|
||||
try:
|
||||
self.authToken = self.registry.global_config.get(
|
||||
'hipchat', 'authtoken')
|
||||
# Require that the authtoken is non-null
|
||||
if self.authToken == '':
|
||||
raise jenkins_jobs.errors.JenkinsJobsException(
|
||||
"Hipchat authtoken must not be a blank string")
|
||||
except (ConfigParser.NoSectionError,
|
||||
jenkins_jobs.errors.JenkinsJobsException), e:
|
||||
logger.fatal("The configuration file needs a hipchat section" +
|
||||
" containing authtoken:\n{0}".format(e))
|
||||
sys.exit(1)
|
||||
self.jenkinsUrl = self.registry.global_config.get('jenkins', 'url')
|
||||
|
||||
def gen_xml(self, parser, xml_parent, data):
|
||||
|
Loading…
Reference in New Issue
Block a user