Add tox.ini and pep8, pyflakes cleanup.
Change-Id: I4d6312e92dffd596ae58e55c837e3db3ea7d1c52 Reviewed-on: https://review.openstack.org/11198 Reviewed-by: Monty Taylor <mordred@inaugust.com> Approved: James E. Blair <corvus@inaugust.com> Tested-by: Jenkins
This commit is contained in:
parent
ab1ee4c6c8
commit
fb0a113eff
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
*.pyc
|
*.pyc
|
||||||
*.egg-info
|
*.egg-info
|
||||||
config
|
config
|
||||||
|
.tox
|
||||||
|
@ -21,15 +21,9 @@ import yaml
|
|||||||
import xml.etree.ElementTree as XML
|
import xml.etree.ElementTree as XML
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
import jenkins
|
import jenkins
|
||||||
import ConfigParser
|
|
||||||
from StringIO import StringIO
|
|
||||||
import re
|
import re
|
||||||
import pkgutil
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import pprint
|
|
||||||
import sys
|
|
||||||
|
|
||||||
class JenkinsJobsException(Exception): pass
|
|
||||||
|
|
||||||
class YamlParser(object):
|
class YamlParser(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -115,11 +109,16 @@ class YamlParser(object):
|
|||||||
def gen_xml(self, xml, data):
|
def gen_xml(self, xml, data):
|
||||||
XML.SubElement(xml, 'actions')
|
XML.SubElement(xml, 'actions')
|
||||||
description = XML.SubElement(xml, 'description')
|
description = XML.SubElement(xml, 'description')
|
||||||
description.text = "THIS JOB IS MANAGED BY PUPPET AND WILL BE OVERWRITTEN.\n\n\
|
description.text = """THIS JOB IS MANAGED BY PUPPET \
|
||||||
DON'T EDIT THIS JOB THROUGH THE WEB\n\n\
|
AND WILL BE OVERWRITTEN.
|
||||||
If you would like to make changes to this job, please see:\n\n\
|
|
||||||
https://github.com/openstack/openstack-ci-puppet\n\n\
|
DON'T EDIT THIS JOB THROUGH THE WEB
|
||||||
In modules/jenkins_jobs"
|
|
||||||
|
If you would like to make changes to this job, please see:
|
||||||
|
|
||||||
|
https://github.com/openstack/openstack-ci-puppet
|
||||||
|
|
||||||
|
In modules/jenkins_jobs"""
|
||||||
XML.SubElement(xml, 'keepDependencies').text = 'false'
|
XML.SubElement(xml, 'keepDependencies').text = 'false'
|
||||||
if data.get('disabled'):
|
if data.get('disabled'):
|
||||||
XML.SubElement(xml, 'disabled').text = 'true'
|
XML.SubElement(xml, 'disabled').text = 'true'
|
||||||
@ -138,8 +137,6 @@ In modules/jenkins_jobs"
|
|||||||
|
|
||||||
|
|
||||||
class ModuleRegistry(object):
|
class ModuleRegistry(object):
|
||||||
# TODO: make this extensible
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.modules = []
|
self.modules = []
|
||||||
self.handlers = {}
|
self.handlers = {}
|
||||||
@ -160,6 +157,7 @@ class ModuleRegistry(object):
|
|||||||
def getHandler(self, category, name):
|
def getHandler(self, category, name):
|
||||||
return self.handlers[category][name]
|
return self.handlers[category][name]
|
||||||
|
|
||||||
|
|
||||||
class XmlJob(object):
|
class XmlJob(object):
|
||||||
def __init__(self, xml, name):
|
def __init__(self, xml, name):
|
||||||
self.xml = xml
|
self.xml = xml
|
||||||
@ -168,11 +166,13 @@ class XmlJob(object):
|
|||||||
def md5(self):
|
def md5(self):
|
||||||
return hashlib.md5(self.output()).hexdigest()
|
return hashlib.md5(self.output()).hexdigest()
|
||||||
|
|
||||||
# Pretty printing ideas from http://stackoverflow.com/questions/749796/pretty-printing-xml-in-python
|
# Pretty printing ideas from
|
||||||
|
# http://stackoverflow.com/questions/749796/pretty-printing-xml-in-python
|
||||||
pretty_text_re = re.compile('>\n\s+([^<>\s].*?)\n\s+</', re.DOTALL)
|
pretty_text_re = re.compile('>\n\s+([^<>\s].*?)\n\s+</', re.DOTALL)
|
||||||
|
|
||||||
def output(self):
|
def output(self):
|
||||||
out = minidom.parseString(XML.tostring(self.xml)).toprettyxml(indent=' ')
|
out = minidom.parseString(XML.tostring(self.xml))
|
||||||
|
out = out.toprettyxml(indent=' ')
|
||||||
return self.pretty_text_re.sub('>\g<1></', out)
|
return self.pretty_text_re.sub('>\g<1></', out)
|
||||||
|
|
||||||
|
|
||||||
@ -194,15 +194,16 @@ class CacheStorage(object):
|
|||||||
yfile.close()
|
yfile.close()
|
||||||
|
|
||||||
def is_cached(self, job):
|
def is_cached(self, job):
|
||||||
if self.data.has_key(job):
|
if job in self.data:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def has_changed(self, job, md5):
|
def has_changed(self, job, md5):
|
||||||
if self.data.has_key(job) and self.data[job] == md5:
|
if job in self.data and self.data[job] == md5:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class Jenkins(object):
|
class Jenkins(object):
|
||||||
def __init__(self, url, user, password):
|
def __init__(self, url, user, password):
|
||||||
self.jenkins = jenkins.Jenkins(url, user, password)
|
self.jenkins = jenkins.Jenkins(url, user, password)
|
||||||
@ -224,6 +225,7 @@ class Jenkins(object):
|
|||||||
if self.is_job(job_name):
|
if self.is_job(job_name):
|
||||||
self.jenkins.delete_job(job_name)
|
self.jenkins.delete_job(job_name)
|
||||||
|
|
||||||
|
|
||||||
class Builder(object):
|
class Builder(object):
|
||||||
def __init__(self, jenkins_url, jenkins_user, jenkins_password):
|
def __init__(self, jenkins_url, jenkins_user, jenkins_password):
|
||||||
self.jenkins = Jenkins(jenkins_url, jenkins_user, jenkins_password)
|
self.jenkins = Jenkins(jenkins_url, jenkins_user, jenkins_password)
|
||||||
@ -266,6 +268,3 @@ class Builder(object):
|
|||||||
if self.cache.has_changed(job.name, md5):
|
if self.cache.has_changed(job.name, md5):
|
||||||
self.jenkins.update_job(job.name, job.output())
|
self.jenkins.update_job(job.name, job.output())
|
||||||
self.cache.set(job.name, md5)
|
self.cache.set(job.name, md5)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,13 +20,13 @@
|
|||||||
|
|
||||||
import xml.etree.ElementTree as XML
|
import xml.etree.ElementTree as XML
|
||||||
import jenkins_jobs.modules.base
|
import jenkins_jobs.modules.base
|
||||||
import pkg_resources
|
|
||||||
import yaml
|
|
||||||
|
|
||||||
def shell(parser, xml_parent, data):
|
def shell(parser, xml_parent, data):
|
||||||
shell = XML.SubElement(xml_parent, 'hudson.tasks.Shell')
|
shell = XML.SubElement(xml_parent, 'hudson.tasks.Shell')
|
||||||
XML.SubElement(shell, 'command').text = data
|
XML.SubElement(shell, 'command').text = data
|
||||||
|
|
||||||
|
|
||||||
def trigger_builds(parser, xml_parent, data):
|
def trigger_builds(parser, xml_parent, data):
|
||||||
tbuilder = XML.SubElement(xml_parent,
|
tbuilder = XML.SubElement(xml_parent,
|
||||||
'hudson.plugins.parameterizedtrigger.TriggerBuilder')
|
'hudson.plugins.parameterizedtrigger.TriggerBuilder')
|
||||||
@ -35,7 +35,7 @@ def trigger_builds(parser, xml_parent, data):
|
|||||||
tconfig = XML.SubElement(configs,
|
tconfig = XML.SubElement(configs,
|
||||||
'hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig')
|
'hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig')
|
||||||
tconfigs = XML.SubElement(tconfig, 'configs')
|
tconfigs = XML.SubElement(tconfig, 'configs')
|
||||||
if project_def.has_key('predefined-parameters'):
|
if 'predefined-parameters' in project_def:
|
||||||
params = XML.SubElement(tconfigs,
|
params = XML.SubElement(tconfigs,
|
||||||
'hudson.plugins.parameterizedtrigger.PredefinedBuildParameters')
|
'hudson.plugins.parameterizedtrigger.PredefinedBuildParameters')
|
||||||
properties = XML.SubElement(params, 'properties')
|
properties = XML.SubElement(params, 'properties')
|
||||||
@ -46,11 +46,14 @@ def trigger_builds(parser, xml_parent, data):
|
|||||||
projects.text = project_def['project']
|
projects.text = project_def['project']
|
||||||
condition = XML.SubElement(tconfig, 'condition')
|
condition = XML.SubElement(tconfig, 'condition')
|
||||||
condition.text = 'ALWAYS'
|
condition.text = 'ALWAYS'
|
||||||
trigger_with_no_params = XML.SubElement(tconfig, 'triggerWithNoParameters')
|
trigger_with_no_params = XML.SubElement(tconfig,
|
||||||
|
'triggerWithNoParameters')
|
||||||
trigger_with_no_params.text = 'false'
|
trigger_with_no_params.text = 'false'
|
||||||
build_all_nodes_with_label = XML.SubElement(tconfig, 'buildAllNodesWithLabel')
|
build_all_nodes_with_label = XML.SubElement(tconfig,
|
||||||
|
'buildAllNodesWithLabel')
|
||||||
build_all_nodes_with_label.text = 'false'
|
build_all_nodes_with_label.text = 'false'
|
||||||
|
|
||||||
|
|
||||||
class Builders(jenkins_jobs.modules.base.Base):
|
class Builders(jenkins_jobs.modules.base.Base):
|
||||||
sequence = 60
|
sequence = 60
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class LogRotate(jenkins_jobs.modules.base.Base):
|
|||||||
sequence = 10
|
sequence = 10
|
||||||
|
|
||||||
def gen_xml(self, parser, xml_parent, data):
|
def gen_xml(self, parser, xml_parent, data):
|
||||||
if data.has_key('logrotate'):
|
if 'logrotate' in data:
|
||||||
lr_xml = XML.SubElement(xml_parent, 'logRotator')
|
lr_xml = XML.SubElement(xml_parent, 'logRotator')
|
||||||
logrotate = data['logrotate']
|
logrotate = data['logrotate']
|
||||||
lr_days = XML.SubElement(lr_xml, 'daysToKeep')
|
lr_days = XML.SubElement(lr_xml, 'daysToKeep')
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
import xml.etree.ElementTree as XML
|
import xml.etree.ElementTree as XML
|
||||||
import jenkins_jobs.modules.base
|
import jenkins_jobs.modules.base
|
||||||
|
|
||||||
|
|
||||||
class Maven(jenkins_jobs.modules.base.Base):
|
class Maven(jenkins_jobs.modules.base.Base):
|
||||||
sequence = 0
|
sequence = 0
|
||||||
|
|
||||||
|
@ -18,12 +18,14 @@
|
|||||||
import xml.etree.ElementTree as XML
|
import xml.etree.ElementTree as XML
|
||||||
import jenkins_jobs.modules.base
|
import jenkins_jobs.modules.base
|
||||||
|
|
||||||
|
|
||||||
def github(parser, xml_parent, data):
|
def github(parser, xml_parent, data):
|
||||||
github = XML.SubElement(xml_parent,
|
github = XML.SubElement(xml_parent,
|
||||||
'com.coravy.hudson.plugins.github.GithubProjectProperty')
|
'com.coravy.hudson.plugins.github.GithubProjectProperty')
|
||||||
github_url = XML.SubElement(github, 'projectUrl')
|
github_url = XML.SubElement(github, 'projectUrl')
|
||||||
github_url.text = data['url']
|
github_url.text = data['url']
|
||||||
|
|
||||||
|
|
||||||
def throttle(parser, xml_parent, data):
|
def throttle(parser, xml_parent, data):
|
||||||
throttle = XML.SubElement(xml_parent,
|
throttle = XML.SubElement(xml_parent,
|
||||||
'hudson.plugins.throttleconcurrents.ThrottleJobProperty')
|
'hudson.plugins.throttleconcurrents.ThrottleJobProperty')
|
||||||
@ -40,6 +42,7 @@ def throttle(parser, xml_parent, data):
|
|||||||
XML.SubElement(throttle, 'throttleOption').text = data.get('option')
|
XML.SubElement(throttle, 'throttleOption').text = data.get('option')
|
||||||
XML.SubElement(throttle, 'configVersion').text = '1'
|
XML.SubElement(throttle, 'configVersion').text = '1'
|
||||||
|
|
||||||
|
|
||||||
def authenticated_build(parser, xml_parent, data):
|
def authenticated_build(parser, xml_parent, data):
|
||||||
# TODO: generalize this
|
# TODO: generalize this
|
||||||
if data:
|
if data:
|
||||||
@ -48,6 +51,7 @@ def authenticated_build(parser, xml_parent, data):
|
|||||||
XML.SubElement(security, 'permission').text = \
|
XML.SubElement(security, 'permission').text = \
|
||||||
'hudson.model.Item.Build:authenticated'
|
'hudson.model.Item.Build:authenticated'
|
||||||
|
|
||||||
|
|
||||||
def base_param(parser, xml_parent, data, do_default, ptype):
|
def base_param(parser, xml_parent, data, do_default, ptype):
|
||||||
pdef = XML.SubElement(xml_parent, ptype)
|
pdef = XML.SubElement(xml_parent, ptype)
|
||||||
XML.SubElement(pdef, 'name').text = data['name']
|
XML.SubElement(pdef, 'name').text = data['name']
|
||||||
@ -59,26 +63,32 @@ def base_param(parser, xml_parent, data, do_default, ptype):
|
|||||||
else:
|
else:
|
||||||
XML.SubElement(pdef, 'defaultValue')
|
XML.SubElement(pdef, 'defaultValue')
|
||||||
|
|
||||||
|
|
||||||
def string_param(parser, xml_parent, data):
|
def string_param(parser, xml_parent, data):
|
||||||
base_param(parser, xml_parent, data, True,
|
base_param(parser, xml_parent, data, True,
|
||||||
'hudson.model.StringParameterDefinition')
|
'hudson.model.StringParameterDefinition')
|
||||||
|
|
||||||
|
|
||||||
def bool_param(parser, xml_parent, data):
|
def bool_param(parser, xml_parent, data):
|
||||||
base_param(parser, xml_parent, data, True,
|
base_param(parser, xml_parent, data, True,
|
||||||
'hudson.model.BooleanParameterDefinition')
|
'hudson.model.BooleanParameterDefinition')
|
||||||
|
|
||||||
|
|
||||||
def file_param(parser, xml_parent, data):
|
def file_param(parser, xml_parent, data):
|
||||||
base_param(parser, xml_parent, data, False,
|
base_param(parser, xml_parent, data, False,
|
||||||
'hudson.model.FileParameterDefinition')
|
'hudson.model.FileParameterDefinition')
|
||||||
|
|
||||||
|
|
||||||
def text_param(parser, xml_parent, data):
|
def text_param(parser, xml_parent, data):
|
||||||
base_param(parser, xml_parent, data, True,
|
base_param(parser, xml_parent, data, True,
|
||||||
'hudson.model.TextParameterDefinition')
|
'hudson.model.TextParameterDefinition')
|
||||||
|
|
||||||
|
|
||||||
def label_param(parser, xml_parent, data):
|
def label_param(parser, xml_parent, data):
|
||||||
base_param(parser, xml_parent, data, True,
|
base_param(parser, xml_parent, data, True,
|
||||||
'org.jvnet.jenkins.plugins.nodelabelparameter.LabelParameterDefinition')
|
'org.jvnet.jenkins.plugins.nodelabelparameter.LabelParameterDefinition')
|
||||||
|
|
||||||
|
|
||||||
def http_endpoint(parser, xml_parent, data):
|
def http_endpoint(parser, xml_parent, data):
|
||||||
endpoint_element = XML.SubElement(xml_parent,
|
endpoint_element = XML.SubElement(xml_parent,
|
||||||
'com.tikal.hudson.plugins.notification.Endpoint')
|
'com.tikal.hudson.plugins.notification.Endpoint')
|
||||||
@ -114,4 +124,3 @@ class Properties(jenkins_jobs.modules.base.Base):
|
|||||||
for endpoint in notifications:
|
for endpoint in notifications:
|
||||||
self._dispatch('notification', 'notifications',
|
self._dispatch('notification', 'notifications',
|
||||||
parser, endpoints_element, endpoint)
|
parser, endpoints_element, endpoint)
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
import xml.etree.ElementTree as XML
|
import xml.etree.ElementTree as XML
|
||||||
import jenkins_jobs.modules.base
|
import jenkins_jobs.modules.base
|
||||||
|
|
||||||
|
|
||||||
def archive(parser, xml_parent, data):
|
def archive(parser, xml_parent, data):
|
||||||
archiver = XML.SubElement(xml_parent, 'hudson.tasks.ArtifactArchiver')
|
archiver = XML.SubElement(xml_parent, 'hudson.tasks.ArtifactArchiver')
|
||||||
artifacts = XML.SubElement(archiver, 'artifacts')
|
artifacts = XML.SubElement(archiver, 'artifacts')
|
||||||
@ -32,6 +33,7 @@ def archive(parser, xml_parent, data):
|
|||||||
else:
|
else:
|
||||||
latest.text = 'false'
|
latest.text = 'false'
|
||||||
|
|
||||||
|
|
||||||
def trigger_parameterized_builds(parser, xml_parent, data):
|
def trigger_parameterized_builds(parser, xml_parent, data):
|
||||||
tbuilder = XML.SubElement(xml_parent,
|
tbuilder = XML.SubElement(xml_parent,
|
||||||
'hudson.plugins.parameterizedtrigger.BuildTrigger')
|
'hudson.plugins.parameterizedtrigger.BuildTrigger')
|
||||||
@ -40,7 +42,7 @@ def trigger_parameterized_builds(parser, xml_parent, data):
|
|||||||
tconfig = XML.SubElement(configs,
|
tconfig = XML.SubElement(configs,
|
||||||
'hudson.plugins.parameterizedtrigger.BuildTriggerConfig')
|
'hudson.plugins.parameterizedtrigger.BuildTriggerConfig')
|
||||||
tconfigs = XML.SubElement(tconfig, 'configs')
|
tconfigs = XML.SubElement(tconfig, 'configs')
|
||||||
if project_def.has_key('predefined-parameters'):
|
if 'predefined-parameters' in project_def:
|
||||||
params = XML.SubElement(tconfigs,
|
params = XML.SubElement(tconfigs,
|
||||||
'hudson.plugins.parameterizedtrigger.PredefinedBuildParameters')
|
'hudson.plugins.parameterizedtrigger.PredefinedBuildParameters')
|
||||||
properties = XML.SubElement(params, 'properties')
|
properties = XML.SubElement(params, 'properties')
|
||||||
@ -55,6 +57,7 @@ def trigger_parameterized_builds(parser, xml_parent, data):
|
|||||||
'triggerWithNoParameters')
|
'triggerWithNoParameters')
|
||||||
trigger_with_no_params.text = 'false'
|
trigger_with_no_params.text = 'false'
|
||||||
|
|
||||||
|
|
||||||
def coverage(parser, xml_parent, data):
|
def coverage(parser, xml_parent, data):
|
||||||
cobertura = XML.SubElement(xml_parent,
|
cobertura = XML.SubElement(xml_parent,
|
||||||
'hudson.plugins.cobertura.CoberturaPublisher')
|
'hudson.plugins.cobertura.CoberturaPublisher')
|
||||||
@ -123,40 +126,6 @@ def coverage(parser, xml_parent, data):
|
|||||||
# docs.openstack.org $ftpdir/dest/dir exluding the excluded file type.
|
# docs.openstack.org $ftpdir/dest/dir exluding the excluded file type.
|
||||||
|
|
||||||
def ftp(parser, xml_parent, data):
|
def ftp(parser, xml_parent, data):
|
||||||
"""
|
|
||||||
Example XML:
|
|
||||||
<publishers>
|
|
||||||
<jenkins.plugins.publish__over__ftp.BapFtpPublisherPlugin>
|
|
||||||
<consolePrefix>FTP: </consolePrefix>
|
|
||||||
<delegate>
|
|
||||||
<publishers>
|
|
||||||
<jenkins.plugins.publish__over__ftp.BapFtpPublisher>
|
|
||||||
<configName>docs.openstack.org</configName>
|
|
||||||
<verbose>true</verbose>
|
|
||||||
<transfers>
|
|
||||||
<jenkins.plugins.publish__over__ftp.BapFtpTransfer>
|
|
||||||
<remoteDirectory></remoteDirectory>
|
|
||||||
<sourceFiles>openstack-identity-api/target/docbkx/webhelp/api/openstack-identity-service/2.0/**</sourceFiles>
|
|
||||||
<excludes>**/*.xml,**/null*</excludes>
|
|
||||||
<removePrefix>openstack-identity-api/target/docbkx/webhelp</removePrefix>
|
|
||||||
<remoteDirectorySDF>false</remoteDirectorySDF>
|
|
||||||
<flatten>false</flatten>
|
|
||||||
<cleanRemote>false</cleanRemote>
|
|
||||||
<asciiMode>false</asciiMode>
|
|
||||||
</jenkins.plugins.publish__over__ftp.BapFtpTransfer>
|
|
||||||
</transfers>
|
|
||||||
<useWorkspaceInPromotion>false</useWorkspaceInPromotion>
|
|
||||||
<usePromotionTimestamp>false</usePromotionTimestamp>
|
|
||||||
</jenkins.plugins.publish__over__ftp.BapFtpPublisher>
|
|
||||||
</publishers>
|
|
||||||
<continueOnError>false</continueOnError>
|
|
||||||
<failOnError>false</failOnError>
|
|
||||||
<alwaysPublishFromMaster>false</alwaysPublishFromMaster>
|
|
||||||
<hostConfigurationAccess class="jenkins.plugins.publish_over_ftp.BapFtpPublisherPlugin" reference="../.."/>
|
|
||||||
</delegate>
|
|
||||||
</jenkins.plugins.publish__over__ftp.BapFtpPublisherPlugin>
|
|
||||||
</publishers>
|
|
||||||
"""
|
|
||||||
outer_ftp = XML.SubElement(xml_parent,
|
outer_ftp = XML.SubElement(xml_parent,
|
||||||
'jenkins.plugins.publish__over__ftp.BapFtpPublisherPlugin')
|
'jenkins.plugins.publish__over__ftp.BapFtpPublisherPlugin')
|
||||||
XML.SubElement(outer_ftp, 'consolePrefix').text = 'FTP: '
|
XML.SubElement(outer_ftp, 'consolePrefix').text = 'FTP: '
|
||||||
@ -168,7 +137,8 @@ def ftp(parser, xml_parent, data):
|
|||||||
XML.SubElement(ftp, 'verbose').text = 'true'
|
XML.SubElement(ftp, 'verbose').text = 'true'
|
||||||
|
|
||||||
transfers = XML.SubElement(ftp, 'transfers')
|
transfers = XML.SubElement(ftp, 'transfers')
|
||||||
ftp_transfers = XML.SubElement(transfers, 'jenkins.plugins.publish__over__ftp.BapFtpTransfer')
|
ftp_transfers = XML.SubElement(transfers,
|
||||||
|
'jenkins.plugins.publish__over__ftp.BapFtpTransfer')
|
||||||
XML.SubElement(ftp_transfers, 'remoteDirectory').text = data['target']
|
XML.SubElement(ftp_transfers, 'remoteDirectory').text = data['target']
|
||||||
XML.SubElement(ftp_transfers, 'sourceFiles').text = data['source']
|
XML.SubElement(ftp_transfers, 'sourceFiles').text = data['source']
|
||||||
XML.SubElement(ftp_transfers, 'excludes').text = data['excludes']
|
XML.SubElement(ftp_transfers, 'excludes').text = data['excludes']
|
||||||
@ -187,6 +157,7 @@ def ftp(parser, xml_parent, data):
|
|||||||
{'class': 'jenkins.plugins.publish_over_ftp.BapFtpPublisherPlugin',
|
{'class': 'jenkins.plugins.publish_over_ftp.BapFtpPublisherPlugin',
|
||||||
'reference': '../..'})
|
'reference': '../..'})
|
||||||
|
|
||||||
|
|
||||||
# Jenkins Job module for coverage publishers
|
# Jenkins Job module for coverage publishers
|
||||||
# To use you add the following into your YAML:
|
# To use you add the following into your YAML:
|
||||||
# publisher:
|
# publisher:
|
||||||
@ -211,6 +182,7 @@ def _pep8_add_entry(xml_parent, name):
|
|||||||
XML.SubElement(tconfig, 'usePattern').text = 'false'
|
XML.SubElement(tconfig, 'usePattern').text = 'false'
|
||||||
XML.SubElement(tconfig, 'pattern')
|
XML.SubElement(tconfig, 'pattern')
|
||||||
|
|
||||||
|
|
||||||
# Jenkins Job module for pep8 publishers
|
# Jenkins Job module for pep8 publishers
|
||||||
# No additional YAML needed
|
# No additional YAML needed
|
||||||
|
|
||||||
@ -218,7 +190,8 @@ def pep8(parser, xml_parent, data):
|
|||||||
violations = XML.SubElement(xml_parent,
|
violations = XML.SubElement(xml_parent,
|
||||||
'hudson.plugins.violations.ViolationsPublisher')
|
'hudson.plugins.violations.ViolationsPublisher')
|
||||||
config = XML.SubElement(violations, 'config')
|
config = XML.SubElement(violations, 'config')
|
||||||
suppressions = XML.SubElement(config, 'suppressions', {'class':'tree-set'})
|
suppressions = XML.SubElement(config, 'suppressions',
|
||||||
|
{'class': 'tree-set'})
|
||||||
XML.SubElement(suppressions, 'no-comparator')
|
XML.SubElement(suppressions, 'no-comparator')
|
||||||
configs = XML.SubElement(config, 'typeConfigs')
|
configs = XML.SubElement(config, 'typeConfigs')
|
||||||
XML.SubElement(configs, 'no-comparator')
|
XML.SubElement(configs, 'no-comparator')
|
||||||
@ -254,6 +227,7 @@ def pep8(parser, xml_parent, data):
|
|||||||
XML.SubElement(config, 'fauxProjectPath')
|
XML.SubElement(config, 'fauxProjectPath')
|
||||||
XML.SubElement(config, 'encoding').text = 'default'
|
XML.SubElement(config, 'encoding').text = 'default'
|
||||||
|
|
||||||
|
|
||||||
# Jenkins Job module for generic scp publishing
|
# Jenkins Job module for generic scp publishing
|
||||||
# To use you add the following into your YAML:
|
# To use you add the following into your YAML:
|
||||||
# publish:
|
# publish:
|
||||||
@ -276,6 +250,7 @@ def scp(parser, xml_parent, data):
|
|||||||
else:
|
else:
|
||||||
XML.SubElement(entry, 'keepHierarchy').text = 'false'
|
XML.SubElement(entry, 'keepHierarchy').text = 'false'
|
||||||
|
|
||||||
|
|
||||||
class Publishers(jenkins_jobs.modules.base.Base):
|
class Publishers(jenkins_jobs.modules.base.Base):
|
||||||
sequence = 70
|
sequence = 70
|
||||||
|
|
||||||
@ -285,6 +260,3 @@ class Publishers(jenkins_jobs.modules.base.Base):
|
|||||||
for action in data.get('publishers', []):
|
for action in data.get('publishers', []):
|
||||||
self._dispatch('publisher', 'publishers',
|
self._dispatch('publisher', 'publishers',
|
||||||
parser, publishers, action)
|
parser, publishers, action)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
import xml.etree.ElementTree as XML
|
import xml.etree.ElementTree as XML
|
||||||
import jenkins_jobs.modules.base
|
import jenkins_jobs.modules.base
|
||||||
|
|
||||||
|
|
||||||
def git(self, xml_parent, data):
|
def git(self, xml_parent, data):
|
||||||
scm = XML.SubElement(xml_parent,
|
scm = XML.SubElement(xml_parent,
|
||||||
'scm', {'class': 'hudson.plugins.git.GitSCM'})
|
'scm', {'class': 'hudson.plugins.git.GitSCM'})
|
||||||
@ -58,6 +59,7 @@ def git(self, xml_parent, data):
|
|||||||
XML.SubElement(scm, 'skipTag').text = 'false'
|
XML.SubElement(scm, 'skipTag').text = 'false'
|
||||||
XML.SubElement(scm, 'scmName')
|
XML.SubElement(scm, 'scmName')
|
||||||
|
|
||||||
|
|
||||||
class SCM(jenkins_jobs.modules.base.Base):
|
class SCM(jenkins_jobs.modules.base.Base):
|
||||||
sequence = 30
|
sequence = 30
|
||||||
|
|
||||||
@ -69,4 +71,3 @@ class SCM(jenkins_jobs.modules.base.Base):
|
|||||||
parser, xml_parent, scm)
|
parser, xml_parent, scm)
|
||||||
else:
|
else:
|
||||||
XML.SubElement(xml_parent, 'scm', {'class': 'hudson.scm.NullSCM'})
|
XML.SubElement(xml_parent, 'scm', {'class': 'hudson.scm.NullSCM'})
|
||||||
|
|
||||||
|
@ -24,7 +24,11 @@
|
|||||||
# overrideVotes: 'true'
|
# overrideVotes: 'true'
|
||||||
# gerritBuildSuccessfulVerifiedValue: 1
|
# gerritBuildSuccessfulVerifiedValue: 1
|
||||||
# gerritBuildFailedVerifiedValue: -1
|
# gerritBuildFailedVerifiedValue: -1
|
||||||
# failureMessage: 'This change was unable to be automatically merged with the current state of the repository. Please rebase your change and upload a new patchset.'
|
#
|
||||||
|
# failureMessage: 'This change was unable to be automatically merged
|
||||||
|
# with the current state of the repository. Please rebase your change
|
||||||
|
# and upload a new patchset.'
|
||||||
|
#
|
||||||
# projects:
|
# projects:
|
||||||
# - projectCompareType: 'PLAIN'
|
# - projectCompareType: 'PLAIN'
|
||||||
# projectPattern: 'openstack/nova'
|
# projectPattern: 'openstack/nova'
|
||||||
@ -36,11 +40,13 @@
|
|||||||
# branchPattern: '**'
|
# branchPattern: '**'
|
||||||
# ...
|
# ...
|
||||||
#
|
#
|
||||||
# triggerApprovalCategory and triggerApprovalValue only required if triggerOnCommentAddedEvent: 'true'
|
# triggerApprovalCategory and triggerApprovalValue only required
|
||||||
|
# if triggerOnCommentAddedEvent: 'true'
|
||||||
|
|
||||||
import xml.etree.ElementTree as XML
|
import xml.etree.ElementTree as XML
|
||||||
import jenkins_jobs.modules.base
|
import jenkins_jobs.modules.base
|
||||||
|
|
||||||
|
|
||||||
def gerrit(parser, xml_parent, data):
|
def gerrit(parser, xml_parent, data):
|
||||||
projects = data['projects']
|
projects = data['projects']
|
||||||
gtrig = XML.SubElement(xml_parent,
|
gtrig = XML.SubElement(xml_parent,
|
||||||
@ -71,7 +77,7 @@ def gerrit(parser, xml_parent, data):
|
|||||||
data['triggerOnCommentAddedEvent']
|
data['triggerOnCommentAddedEvent']
|
||||||
XML.SubElement(gtrig, 'triggerOnRefUpdatedEvent').text = \
|
XML.SubElement(gtrig, 'triggerOnRefUpdatedEvent').text = \
|
||||||
data['triggerOnRefUpdatedEvent']
|
data['triggerOnRefUpdatedEvent']
|
||||||
if data.has_key('overrideVotes') and data['overrideVotes'] == 'true':
|
if 'overrideVotes' in data and data['overrideVotes'] == 'true':
|
||||||
XML.SubElement(gtrig, 'gerritBuildSuccessfulVerifiedValue').text = \
|
XML.SubElement(gtrig, 'gerritBuildSuccessfulVerifiedValue').text = \
|
||||||
str(data['gerritBuildSuccessfulVerifiedValue'])
|
str(data['gerritBuildSuccessfulVerifiedValue'])
|
||||||
XML.SubElement(gtrig, 'gerritBuildFailedVerifiedValue').text = \
|
XML.SubElement(gtrig, 'gerritBuildFailedVerifiedValue').text = \
|
||||||
@ -87,6 +93,7 @@ def gerrit(parser, xml_parent, data):
|
|||||||
XML.SubElement(gtrig, 'buildUnstableMessage')
|
XML.SubElement(gtrig, 'buildUnstableMessage')
|
||||||
XML.SubElement(gtrig, 'customUrl')
|
XML.SubElement(gtrig, 'customUrl')
|
||||||
|
|
||||||
|
|
||||||
# Jenkins Job module for scm polling triggers
|
# Jenkins Job module for scm polling triggers
|
||||||
# To use add the following into your YAML:
|
# To use add the following into your YAML:
|
||||||
# trigger:
|
# trigger:
|
||||||
@ -98,6 +105,7 @@ def pollscm(parser, xml_parent, data):
|
|||||||
scmtrig = XML.SubElement(xml_parent, 'hudson.triggers.SCMTrigger')
|
scmtrig = XML.SubElement(xml_parent, 'hudson.triggers.SCMTrigger')
|
||||||
XML.SubElement(scmtrig, 'spec').text = data
|
XML.SubElement(scmtrig, 'spec').text = data
|
||||||
|
|
||||||
|
|
||||||
# Jenkins Job module for timed triggers
|
# Jenkins Job module for timed triggers
|
||||||
# To use add the following into your YAML:
|
# To use add the following into your YAML:
|
||||||
# trigger:
|
# trigger:
|
||||||
@ -109,6 +117,7 @@ def timed(parser, xml_parent, data):
|
|||||||
scmtrig = XML.SubElement(xml_parent, 'hudson.triggers.TimerTrigger')
|
scmtrig = XML.SubElement(xml_parent, 'hudson.triggers.TimerTrigger')
|
||||||
XML.SubElement(scmtrig, 'spec').text = data
|
XML.SubElement(scmtrig, 'spec').text = data
|
||||||
|
|
||||||
|
|
||||||
class Triggers(jenkins_jobs.modules.base.Base):
|
class Triggers(jenkins_jobs.modules.base.Base):
|
||||||
sequence = 50
|
sequence = 50
|
||||||
|
|
||||||
@ -121,4 +130,3 @@ class Triggers(jenkins_jobs.modules.base.Base):
|
|||||||
for trigger in triggers:
|
for trigger in triggers:
|
||||||
self._dispatch('trigger', 'triggers',
|
self._dispatch('trigger', 'triggers',
|
||||||
parser, trig_e, trigger)
|
parser, trig_e, trigger)
|
||||||
|
|
||||||
|
@ -30,10 +30,12 @@ def timeout(parser, xml_parent, data):
|
|||||||
else:
|
else:
|
||||||
failbuild.text = 'false'
|
failbuild.text = 'false'
|
||||||
|
|
||||||
|
|
||||||
def timestamps(parser, xml_parent, data):
|
def timestamps(parser, xml_parent, data):
|
||||||
XML.SubElement(xml_parent,
|
XML.SubElement(xml_parent,
|
||||||
'hudson.plugins.timestamper.TimestamperBuildWrapper')
|
'hudson.plugins.timestamper.TimestamperBuildWrapper')
|
||||||
|
|
||||||
|
|
||||||
def ansicolor(parser, xml_parent, data):
|
def ansicolor(parser, xml_parent, data):
|
||||||
XML.SubElement(xml_parent,
|
XML.SubElement(xml_parent,
|
||||||
'hudson.plugins.ansicolor.AnsiColorBuildWrapper')
|
'hudson.plugins.ansicolor.AnsiColorBuildWrapper')
|
||||||
@ -48,4 +50,3 @@ class Wrappers(jenkins_jobs.modules.base.Base):
|
|||||||
for wrap in data.get('wrappers', []):
|
for wrap in data.get('wrappers', []):
|
||||||
self._dispatch('wrapper', 'wrappers',
|
self._dispatch('wrapper', 'wrappers',
|
||||||
parser, wrappers, wrap)
|
parser, wrappers, wrap)
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ ZUUL_NOTIFICATIONS = [
|
|||||||
{'url': 'http://127.0.0.1:8001/jenkins_endpoint'}}
|
{'url': 'http://127.0.0.1:8001/jenkins_endpoint'}}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class Zuul(jenkins_jobs.modules.base.Base):
|
class Zuul(jenkins_jobs.modules.base.Base):
|
||||||
sequence = 0
|
sequence = 0
|
||||||
|
|
||||||
|
16
tox.ini
Normal file
16
tox.ini
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[tox]
|
||||||
|
envlist = pep8, pyflakes
|
||||||
|
|
||||||
|
[tox:jenkins]
|
||||||
|
downloadcache = ~/cache/pip
|
||||||
|
|
||||||
|
[testenv:pep8]
|
||||||
|
deps = pep8==1.2
|
||||||
|
commands = pep8 --repeat --show-source --exclude=.venv,.tox,dist,doc,build .
|
||||||
|
|
||||||
|
[testenv:pyflakes]
|
||||||
|
deps = pyflakes
|
||||||
|
commands = pyflakes jenkins_jobs jenkins-jobs setup.py
|
||||||
|
|
||||||
|
[testenv:venv]
|
||||||
|
commands = {posargs}
|
Loading…
Reference in New Issue
Block a user