Correct configuration file usage.

This corrects the issue where a config file in a standard location is
not used if --conf <file> is not passed on the command line.

Change-Id: I4a17d342f2751359381658a545441465d4a42a9b
Signed-off-by: Philip Marc Schwartz <philip@progmad.com>
This commit is contained in:
Philip Marc Schwartz 2016-07-27 14:09:43 -04:00 committed by Wayne Warren
parent a88104422e
commit 0988c99327

View File

@ -50,6 +50,9 @@ authtoken=dummy
send-as=Jenkins
"""
CONFIG_REQUIRED_MESSAGE = ("A valid configuration file is required. "
"No configuration file passed.")
class JJBConfig(object):
@ -90,8 +93,7 @@ class JJBConfig(object):
conf = None
if config_filename is not None:
conf = config_filename
elif config_file_required:
else:
if os.path.isfile(local_conf):
conf = local_conf
elif os.path.isfile(user_conf):
@ -99,13 +101,16 @@ class JJBConfig(object):
else:
conf = global_conf
if config_file_required and conf is None:
raise JJBConfigException(CONFIG_REQUIRED_MESSAGE)
config_fp = None
if conf is not None:
try:
config_fp = self._read_config_file(conf)
except JJBConfigException as e:
except JJBConfigException:
if config_file_required:
raise e
raise JJBConfigException(CONFIG_REQUIRED_MESSAGE)
else:
logger.warn("Config file, {0}, not found. Using default "
"config values.".format(conf))