diff options
author | Lars Wirzenius <liw@liw.fi> | 2012-08-11 18:39:46 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2012-08-11 18:39:46 +0100 |
commit | 381a73e5644ea23dae813d4ef3b32319c63c1560 (patch) | |
tree | ca7ee75f6333df7f90b6f72dd7280f48280357ef /simplejenkinsapi | |
parent | aa6ec79044298faf2d9bbbc9a299adb1cefb5568 (diff) | |
download | jenkinstool-381a73e5644ea23dae813d4ef3b32319c63c1560.tar.gz |
Refactor: simplify generation/yielding of job ids
Diffstat (limited to 'simplejenkinsapi')
-rw-r--r-- | simplejenkinsapi/jobconfig.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/simplejenkinsapi/jobconfig.py b/simplejenkinsapi/jobconfig.py index 3bc2773..a53fd54 100644 --- a/simplejenkinsapi/jobconfig.py +++ b/simplejenkinsapi/jobconfig.py @@ -54,7 +54,10 @@ class JobConfig(object): self._project = ET.fromstring(empty) self._tree = ET.ElementTree(self._project) self._param_dicts = [] - + + def set_job_suffix(self, suffix): + self._suffix = suffix + def add_param_dict(self, prefix, param_dict): self._param_dicts.append((prefix, param_dict)) @@ -65,6 +68,20 @@ class JobConfig(object): unified['%s.%s' % (prefix, key)] = param_dict[key] return unified + def job_id(self): + '''Create a unique job id from constituent parts. + + Escape characters that Jenkins gets upset by, such as '@'. + + ''' + + def esc(s): + s = '.'.join(s.split('@')) + return s + + s = '%(project.name)s_%(host.ssh-target)s_' % self._get_params() + return esc(s) + self._suffix + def tostring(self): f = StringIO.StringIO() self._tree.write( |