diff options
author | Thanh Ha <thanh.ha@linuxfoundation.org> | 2016-08-19 11:14:34 -0400 |
---|---|---|
committer | Thanh Ha <thanh.ha@linuxfoundation.org> | 2016-11-11 13:34:16 -0500 |
commit | b093fee5017ca4b71b0856ce88f4e9f3d28f7e3d (patch) | |
tree | 3825a68d4e0007d1ec6e7a20cde542c713120309 /jenkins_jobs/config.py | |
parent | e47f9629bc7483d597602c468619c914c421f8e3 (diff) | |
download | python-jenkins-job-builder-b093fee5017ca4b71b0856ce88f4e9f3d28f7e3d.tar.gz python-jenkins-job-builder-b093fee5017ca4b71b0856ce88f4e9f3d28f7e3d.tar.xz python-jenkins-job-builder-b093fee5017ca4b71b0856ce88f4e9f3d28f7e3d.zip |
Add convenience function for plugin namespace
Plugins can use get_plugin_config() which will search in a plugin
namespace. For example:
[plugin "hipchat"]
authtoken = 123token
- Updated hipchat plugin to use get_plugin_config()
- Updated stash plugin to use get_plugin_config()
- Backwards compatibility is kept by falling back to the old
configuration setting if the new one is not found.
- Warning is displayed if the old configuration method is used.
Change-Id: I7cff063e2d179a5d9a3f221c85de6864382bc477
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
Diffstat (limited to 'jenkins_jobs/config.py')
-rw-r--r-- | jenkins_jobs/config.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/jenkins_jobs/config.py b/jenkins_jobs/config.py index a22c48af..19d13b82 100644 --- a/jenkins_jobs/config.py +++ b/jenkins_jobs/config.py @@ -310,3 +310,18 @@ class JJBConfig(object): " the " + section + " section, blank default" + " value will be applied:\n{0}".format(e)) return result + + def get_plugin_config(self, plugin, key): + value = self.get_module_config('plugin "{}"'.format(plugin), key) + + # Backwards compatibility for users who have not switched to the new + # plugin configuration format in their config. This code should be + # removed in future versions of JJB after 2.0. + if not value: + value = self.get_module_config(plugin, key) + logger.warning( + "Defining plugin configuration using [" + plugin + "] is" + " deprecated. The recommended way to define plugins now is by" + " configuring [plugin \"" + plugin + "\"]") + + return value |