summaryrefslogtreecommitdiffstats
path: root/jenkins_jobs/modules/builders.py
diff options
context:
space:
mode:
Diffstat (limited to 'jenkins_jobs/modules/builders.py')
-rw-r--r--jenkins_jobs/modules/builders.py2807
1 files changed, 1388 insertions, 1419 deletions
diff --git a/jenkins_jobs/modules/builders.py b/jenkins_jobs/modules/builders.py
index 57199cdc..ab70023e 100644
--- a/jenkins_jobs/modules/builders.py
+++ b/jenkins_jobs/modules/builders.py
@@ -80,16 +80,15 @@ def shell(registry, xml_parent, data):
/../../tests/builders/fixtures/shell-unstable-return.yaml
:language: yaml
"""
- shell = XML.SubElement(xml_parent, 'hudson.tasks.Shell')
+ shell = XML.SubElement(xml_parent, "hudson.tasks.Shell")
if isinstance(data, six.string_types):
- XML.SubElement(shell, 'command').text = data
+ XML.SubElement(shell, "command").text = data
else:
mappings = [
- ('command', 'command', None),
- ('unstable-return', 'unstableReturn', 0),
+ ("command", "command", None),
+ ("unstable-return", "unstableReturn", 0),
]
- helpers.convert_mapping_to_xml(
- shell, data, mappings, fail_required=True)
+ helpers.convert_mapping_to_xml(shell, data, mappings, fail_required=True)
def python(registry, xml_parent, data):
@@ -105,8 +104,8 @@ def python(registry, xml_parent, data):
:language: yaml
"""
- python = XML.SubElement(xml_parent, 'hudson.plugins.python.Python')
- XML.SubElement(python, 'command').text = data
+ python = XML.SubElement(xml_parent, "hudson.plugins.python.Python")
+ XML.SubElement(python, "command").text = data
def copyartifact(registry, xml_parent, data):
@@ -185,20 +184,20 @@ def copyartifact(registry, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/copy-artifact004.yaml
:language: yaml
"""
- t = XML.SubElement(xml_parent, 'hudson.plugins.copyartifact.CopyArtifact')
+ t = XML.SubElement(xml_parent, "hudson.plugins.copyartifact.CopyArtifact")
mappings = [
# Warning: this only works with copy artifact version 1.26+,
# for copy artifact version 1.25- the 'projectName' element needs
# to be used instead of 'project'
- ('project', 'project', None),
- ('filter', 'filter', ''),
- ('target', 'target', ''),
- ('flatten', 'flatten', False),
- ('optional', 'optional', False),
- ('do-not-fingerprint', 'doNotFingerprintArtifacts', False),
- ('parameter-filters', 'parameters', ''),
- ('exclude', 'exclude', ''),
- ('result-var-suffix', 'resultVariableSuffix', ''),
+ ("project", "project", None),
+ ("filter", "filter", ""),
+ ("target", "target", ""),
+ ("flatten", "flatten", False),
+ ("optional", "optional", False),
+ ("do-not-fingerprint", "doNotFingerprintArtifacts", False),
+ ("parameter-filters", "parameters", ""),
+ ("exclude", "exclude", ""),
+ ("result-var-suffix", "resultVariableSuffix", ""),
]
helpers.convert_mapping_to_xml(t, data, mappings, fail_required=True)
helpers.copyartifact_build_selector(t, data)
@@ -226,12 +225,13 @@ def change_assembly_version(registry, xml_parent, data):
:language: yaml
"""
- cav_builder_tag = ('org.jenkinsci.plugins.changeassemblyversion.'
- 'ChangeAssemblyVersion')
+ cav_builder_tag = (
+ "org.jenkinsci.plugins.changeassemblyversion." "ChangeAssemblyVersion"
+ )
cav = XML.SubElement(xml_parent, cav_builder_tag)
mappings = [
- ('version', 'task', '1.0.0'),
- ('assembly-file', 'assemblyFile', 'AssemblyInfo.cs'),
+ ("version", "task", "1.0.0"),
+ ("assembly-file", "assemblyFile", "AssemblyInfo.cs"),
]
helpers.convert_mapping_to_xml(cav, data, mappings, fail_required=True)
@@ -258,14 +258,12 @@ def fingerprint(registry, xml_parent, data):
"""
fingerprint = XML.SubElement(
- xml_parent, 'hudson.plugins.createfingerprint.CreateFingerprint')
- fingerprint.set('plugin', 'create-fingerprint')
+ xml_parent, "hudson.plugins.createfingerprint.CreateFingerprint"
+ )
+ fingerprint.set("plugin", "create-fingerprint")
- mapping = [
- ('targets', 'targets', ''),
- ]
- helpers.convert_mapping_to_xml(
- fingerprint, data, mapping, fail_required=True)
+ mapping = [("targets", "targets", "")]
+ helpers.convert_mapping_to_xml(fingerprint, data, mapping, fail_required=True)
def ant(registry, xml_parent, data):
@@ -307,30 +305,30 @@ def ant(registry, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/ant002.yaml
:language: yaml
"""
- ant = XML.SubElement(xml_parent, 'hudson.tasks.Ant')
+ ant = XML.SubElement(xml_parent, "hudson.tasks.Ant")
if type(data) is str:
# Support for short form: -ant: "target"
- data = {'targets': data}
+ data = {"targets": data}
mapping = [
- ('targets', 'targets', None),
- ('buildfile', 'buildFile', None),
- ('ant-name', 'antName', 'default'),
+ ("targets", "targets", None),
+ ("buildfile", "buildFile", None),
+ ("ant-name", "antName", "default"),
]
helpers.convert_mapping_to_xml(ant, data, mapping, fail_required=False)
mapping = []
for setting, value in sorted(data.items()):
- if setting == 'properties':
+ if setting == "properties":
properties = value
- prop_string = ''
+ prop_string = ""
for prop, val in properties.items():
prop_string += "%s=%s\n" % (prop, val)
- mapping.append(('', 'properties', prop_string))
- if setting == 'java-opts':
- jopt_string = '\n'.join(value)
- mapping.append(('', 'antOpts', jopt_string))
+ mapping.append(("", "properties", prop_string))
+ if setting == "java-opts":
+ jopt_string = "\n".join(value)
+ mapping.append(("", "antOpts", jopt_string))
helpers.convert_mapping_to_xml(ant, data, mapping, fail_required=True)
@@ -375,48 +373,48 @@ def trigger_remote(registry, xml_parent, data):
/../../tests/builders/fixtures/trigger-remote/trigger-remote001.yaml
:language: yaml
"""
- triggerr = XML.SubElement(xml_parent,
- 'org.jenkinsci.plugins.'
- 'ParameterizedRemoteTrigger.'
- 'RemoteBuildConfiguration')
+ triggerr = XML.SubElement(
+ xml_parent,
+ "org.jenkinsci.plugins."
+ "ParameterizedRemoteTrigger."
+ "RemoteBuildConfiguration",
+ )
mappings = [
- ('remote-jenkins-name', 'remoteJenkinsName', None),
- ('token', 'token', ''),
- ('job', 'job', None),
- ('should-not-fail-build', 'shouldNotFailBuild', False),
- ('poll-interval', 'pollInterval', 10),
- ('connection-retry-limit', 'connectionRetryLimit', 5),
- ('enhanced-logging', 'enhancedLogging', False),
- ('prevent-remote-build-queue', 'preventRemoteBuildQueue', False),
- ('block', 'blockBuildUntilComplete', True),
+ ("remote-jenkins-name", "remoteJenkinsName", None),
+ ("token", "token", ""),
+ ("job", "job", None),
+ ("should-not-fail-build", "shouldNotFailBuild", False),
+ ("poll-interval", "pollInterval", 10),
+ ("connection-retry-limit", "connectionRetryLimit", 5),
+ ("enhanced-logging", "enhancedLogging", False),
+ ("prevent-remote-build-queue", "preventRemoteBuildQueue", False),
+ ("block", "blockBuildUntilComplete", True),
]
- helpers.convert_mapping_to_xml(
- triggerr, data, mappings, fail_required=True)
+ helpers.convert_mapping_to_xml(triggerr, data, mappings, fail_required=True)
mappings = []
- if 'predefined-parameters' in data:
- parameters = data.get('predefined-parameters', '')
- XML.SubElement(triggerr, 'parameters').text = parameters
+ if "predefined-parameters" in data:
+ parameters = data.get("predefined-parameters", "")
+ XML.SubElement(triggerr, "parameters").text = parameters
params_list = parameters.split("\n")
- parameter_list = XML.SubElement(triggerr, 'parameterList')
+ parameter_list = XML.SubElement(triggerr, "parameterList")
for param in params_list:
- if param == '':
+ if param == "":
continue
- tmp = XML.SubElement(parameter_list, 'string')
+ tmp = XML.SubElement(parameter_list, "string")
tmp.text = param
- if 'property-file' in data and data['property-file'] != '':
- mappings.append(('', 'loadParamsFromFile', 'true'))
- mappings.append(('property-file', 'parameterFile', None))
+ if "property-file" in data and data["property-file"] != "":
+ mappings.append(("", "loadParamsFromFile", "true"))
+ mappings.append(("property-file", "parameterFile", None))
else:
- mappings.append(('', 'loadParamsFromFile', 'false'))
+ mappings.append(("", "loadParamsFromFile", "false"))
- mappings.append(('', 'overrideAuth', 'false'))
+ mappings.append(("", "overrideAuth", "false"))
- helpers.convert_mapping_to_xml(
- triggerr, data, mappings, fail_required=True)
+ helpers.convert_mapping_to_xml(triggerr, data, mappings, fail_required=True)
def trigger_builds(registry, xml_parent, data):
@@ -540,231 +538,259 @@ def trigger_builds(registry, xml_parent, data):
/../../tests/builders/fixtures/trigger-builds-configfactory-multi.yaml
:language: yaml
"""
- tbuilder = XML.SubElement(xml_parent,
- 'hudson.plugins.parameterizedtrigger.'
- 'TriggerBuilder')
- configs = XML.SubElement(tbuilder, 'configs')
+ tbuilder = XML.SubElement(
+ xml_parent, "hudson.plugins.parameterizedtrigger." "TriggerBuilder"
+ )
+ configs = XML.SubElement(tbuilder, "configs")
for project_def in data:
- if 'project' not in project_def or project_def['project'] == '':
+ if "project" not in project_def or project_def["project"] == "":
logger.debug("No project specified - skipping trigger-build")
continue
- tconfig = XML.SubElement(configs,
- 'hudson.plugins.parameterizedtrigger.'
- 'BlockableBuildTriggerConfig')
- tconfigs = XML.SubElement(tconfig, 'configs')
- if(project_def.get('current-parameters')):
- XML.SubElement(tconfigs,
- 'hudson.plugins.parameterizedtrigger.'
- 'CurrentBuildParameters')
- if(project_def.get('svn-revision')):
- XML.SubElement(tconfigs,
- 'hudson.plugins.parameterizedtrigger.'
- 'SubversionRevisionBuildParameters')
-
- if(project_def.get('git-revision')):
- helpers.append_git_revision_config(
- tconfigs, project_def['git-revision'])
-
- if(project_def.get('same-node')):
- XML.SubElement(tconfigs,
- 'hudson.plugins.parameterizedtrigger.'
- 'NodeParameters')
- if 'property-file' in project_def:
- params = XML.SubElement(tconfigs,
- 'hudson.plugins.parameterizedtrigger.'
- 'FileBuildParameters')
- mapping = [
- ('property-file', 'propertiesFile', None),
- ('property-file-fail-on-missing',
- 'failTriggerOnMissing', True),
- ]
- helpers.convert_mapping_to_xml(params,
- project_def, mapping, fail_required=True)
-
- if 'predefined-parameters' in project_def:
- params = XML.SubElement(tconfigs,
- 'hudson.plugins.parameterizedtrigger.'
- 'PredefinedBuildParameters')
+ tconfig = XML.SubElement(
+ configs,
+ "hudson.plugins.parameterizedtrigger." "BlockableBuildTriggerConfig",
+ )
+ tconfigs = XML.SubElement(tconfig, "configs")
+ if project_def.get("current-parameters"):
+ XML.SubElement(
+ tconfigs,
+ "hudson.plugins.parameterizedtrigger." "CurrentBuildParameters",
+ )
+ if project_def.get("svn-revision"):
+ XML.SubElement(
+ tconfigs,
+ "hudson.plugins.parameterizedtrigger."
+ "SubversionRevisionBuildParameters",
+ )
+
+ if project_def.get("git-revision"):
+ helpers.append_git_revision_config(tconfigs, project_def["git-revision"])
+
+ if project_def.get("same-node"):
+ XML.SubElement(
+ tconfigs, "hudson.plugins.parameterizedtrigger." "NodeParameters"
+ )
+ if "property-file" in project_def:
+ params = XML.SubElement(
+ tconfigs, "hudson.plugins.parameterizedtrigger." "FileBuildParameters"
+ )
mapping = [
- ('predefined-parameters', 'properties', None),
+ ("property-file", "propertiesFile", None),
+ ("property-file-fail-on-missing", "failTriggerOnMissing", True),
]
- helpers.convert_mapping_to_xml(params,
- project_def, mapping, fail_required=True)
-
- if 'bool-parameters' in project_def:
- params = XML.SubElement(tconfigs,
- 'hudson.plugins.parameterizedtrigger.'
- 'BooleanParameters')
- configs = XML.SubElement(params, 'configs')
- for bool_param in project_def['bool-parameters']:
- param = XML.SubElement(configs,
- 'hudson.plugins.parameterizedtrigger.'
- 'BooleanParameterConfig')
- mapping = [
- ('name', 'name', None),
- ('value', 'value', False),
- ]
- helpers.convert_mapping_to_xml(param,
- bool_param, mapping, fail_required=True)
-
- if 'node-label-name' in project_def and 'node-label' in project_def:
- node = XML.SubElement(tconfigs, 'org.jvnet.jenkins.plugins.'
- 'nodelabelparameter.parameterizedtrigger.'
- 'NodeLabelBuildParameter')
- mapping = [
- ('node-label-name', 'name', None),
- ('node-label', 'nodeLabel', None),
- ]
- helpers.convert_mapping_to_xml(node,
- project_def, mapping, fail_required=True)
-
- if 'restrict-matrix-project' in project_def:
- params = XML.SubElement(tconfigs,
- 'hudson.plugins.parameterizedtrigger.'
- 'matrix.MatrixSubsetBuildParameters')
+ helpers.convert_mapping_to_xml(
+ params, project_def, mapping, fail_required=True
+ )
+
+ if "predefined-parameters" in project_def:
+ params = XML.SubElement(
+ tconfigs,
+ "hudson.plugins.parameterizedtrigger." "PredefinedBuildParameters",
+ )
+ mapping = [("predefined-parameters", "properties", None)]
+ helpers.convert_mapping_to_xml(
+ params, project_def, mapping, fail_required=True
+ )
+
+ if "bool-parameters" in project_def:
+ params = XML.SubElement(
+ tconfigs, "hudson.plugins.parameterizedtrigger." "BooleanParameters"
+ )
+ configs = XML.SubElement(params, "configs")
+ for bool_param in project_def["bool-parameters"]:
+ param = XML.SubElement(
+ configs,
+ "hudson.plugins.parameterizedtrigger." "BooleanParameterConfig",
+ )
+ mapping = [("name", "name", None), ("value", "value", False)]
+ helpers.convert_mapping_to_xml(
+ param, bool_param, mapping, fail_required=True
+ )
+
+ if "node-label-name" in project_def and "node-label" in project_def:
+ node = XML.SubElement(
+ tconfigs,
+ "org.jvnet.jenkins.plugins."
+ "nodelabelparameter.parameterizedtrigger."
+ "NodeLabelBuildParameter",
+ )
mapping = [
- ('restrict-matrix-project', 'filter', None),
+ ("node-label-name", "name", None),
+ ("node-label", "nodeLabel", None),
]
- helpers.convert_mapping_to_xml(params,
- project_def, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(
+ node, project_def, mapping, fail_required=True
+ )
+
+ if "restrict-matrix-project" in project_def:
+ params = XML.SubElement(
+ tconfigs,
+ "hudson.plugins.parameterizedtrigger."
+ "matrix.MatrixSubsetBuildParameters",
+ )
+ mapping = [("restrict-matrix-project", "filter", None)]
+ helpers.convert_mapping_to_xml(
+ params, project_def, mapping, fail_required=True
+ )
- if(len(list(tconfigs)) == 0):
- tconfigs.set('class', 'java.util.Collections$EmptyList')
+ if len(list(tconfigs)) == 0:
+ tconfigs.set("class", "java.util.Collections$EmptyList")
- if 'parameter-factories' in project_def:
- fconfigs = XML.SubElement(tconfig, 'configFactories')
+ if "parameter-factories" in project_def:
+ fconfigs = XML.SubElement(tconfig, "configFactories")
- supported_factories = ['filebuild',
- 'binaryfile',
- 'counterbuild',
- 'allnodesforlabel',
- 'allonlinenodes']
- supported_actions = ['SKIP', 'NOPARMS', 'FAIL']
- for factory in project_def['parameter-factories']:
+ supported_factories = [
+ "filebuild",
+ "binaryfile",
+ "counterbuild",
+ "allnodesforlabel",
+ "allonlinenodes",
+ ]
+ supported_actions = ["SKIP", "NOPARMS", "FAIL"]
+ for factory in project_def["parameter-factories"]:
- if factory['factory'] not in supported_factories:
- raise InvalidAttributeError('factory',
- factory['factory'],
- supported_factories)
+ if factory["factory"] not in supported_factories:
+ raise InvalidAttributeError(
+ "factory", factory["factory"], supported_factories
+ )
- if factory['factory'] == 'filebuild':
+ if factory["factory"] == "filebuild":
params = XML.SubElement(
fconfigs,
- 'hudson.plugins.parameterizedtrigger.'
- 'FileBuildParameterFactory')
- if factory['factory'] == 'binaryfile':
+ "hudson.plugins.parameterizedtrigger."
+ "FileBuildParameterFactory",
+ )
+ if factory["factory"] == "binaryfile":
params = XML.SubElement(
fconfigs,
- 'hudson.plugins.parameterizedtrigger.'
- 'BinaryFileParameterFactory')
- mapping = [
- ('parameter-name', 'parameterName', None),
- ]
- helpers.convert_mapping_to_xml(params,
- factory, mapping, fail_required=True)
-
- if (factory['factory'] == 'filebuild' or
- factory['factory'] == 'binaryfile'):
+ "hudson.plugins.parameterizedtrigger."
+ "BinaryFileParameterFactory",
+ )
+ mapping = [("parameter-name", "parameterName", None)]
+ helpers.convert_mapping_to_xml(
+ params, factory, mapping, fail_required=True
+ )
+
+ if (
+ factory["factory"] == "filebuild"
+ or factory["factory"] == "binaryfile"
+ ):
mapping = [
- ('file-pattern', 'filePattern', None),
- ('no-files-found-action',
- 'noFilesFoundAction', 'SKIP', supported_actions),
+ ("file-pattern", "filePattern", None),
+ (
+ "no-files-found-action",
+ "noFilesFoundAction",
+ "SKIP",
+ supported_actions,
+ ),
]
- helpers.convert_mapping_to_xml(params,
- factory, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(
+ params, factory, mapping, fail_required=True
+ )
- if factory['factory'] == 'counterbuild':
+ if factory["factory"] == "counterbuild":
params = XML.SubElement(
fconfigs,
- 'hudson.plugins.parameterizedtrigger.'
- 'CounterBuildParameterFactory')
+ "hudson.plugins.parameterizedtrigger."
+ "CounterBuildParameterFactory",
+ )
mapping = [
- ('from', 'from', None),
- ('to', 'to', None),
- ('step', 'step', None),
- ('parameters', 'paramExpr', ''),
- ('validation-fail',
- 'validationFail',
- 'FAIL', supported_actions),
+ ("from", "from", None),
+ ("to", "to", None),
+ ("step", "step", None),
+ ("parameters", "paramExpr", ""),
+ (
+ "validation-fail",
+ "validationFail",
+ "FAIL",
+ supported_actions,
+ ),
]
- helpers.convert_mapping_to_xml(params,
- factory, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(
+ params, factory, mapping, fail_required=True
+ )
- if factory['factory'] == 'allnodesforlabel':
+ if factory["factory"] == "allnodesforlabel":
params = XML.SubElement(
fconfigs,
- 'org.jvnet.jenkins.plugins.nodelabelparameter.'
- 'parameterizedtrigger.'
- 'AllNodesForLabelBuildParameterFactory')
+ "org.jvnet.jenkins.plugins.nodelabelparameter."
+ "parameterizedtrigger."
+ "AllNodesForLabelBuildParameterFactory",
+ )
mapping = [
- ('name', 'name', ''),
- ('node-label', 'nodeLabel', None),
- ('ignore-offline-nodes',
- 'ignoreOfflineNodes', True),
+ ("name", "name", ""),
+ ("node-label", "nodeLabel", None),
+ ("ignore-offline-nodes", "ignoreOfflineNodes", True),
]
- helpers.convert_mapping_to_xml(params,
- factory, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(
+ params, factory, mapping, fail_required=True
+ )
- if factory['factory'] == 'allonlinenodes':
+ if factory["factory"] == "allonlinenodes":
params = XML.SubElement(
fconfigs,
- 'org.jvnet.jenkins.plugins.nodelabelparameter.'
- 'parameterizedtrigger.'
- 'AllNodesBuildParameterFactory')
-
- projects = XML.SubElement(tconfig, 'projects')
- if isinstance(project_def['project'], list):
- projects.text = ",".join(project_def['project'])
+ "org.jvnet.jenkins.plugins.nodelabelparameter."
+ "parameterizedtrigger."
+ "AllNodesBuildParameterFactory",
+ )
+
+ projects = XML.SubElement(tconfig, "projects")
+ if isinstance(project_def["project"], list):
+ projects.text = ",".join(project_def["project"])
else:
- projects.text = project_def['project']
+ projects.text = project_def["project"]
mapping = [
- ('', 'condition', 'ALWAYS'),
- ('', 'triggerWithNoParameters', False),
- ('', 'buildAllNodesWithLabel', False),
+ ("", "condition", "ALWAYS"),
+ ("", "triggerWithNoParameters", False),
+ ("", "buildAllNodesWithLabel", False),
]
- helpers.convert_mapping_to_xml(
- tconfig, {}, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(tconfig, {}, mapping, fail_required=True)
- block = project_def.get('block', False)
+ block = project_def.get("block", False)
if block:
- block = XML.SubElement(tconfig, 'block')
- supported_thresholds = [['build-step-failure-threshold',
- 'buildStepFailureThreshold',
- 'FAILURE'],
- ['unstable-threshold',
- 'unstableThreshold',
- 'UNSTABLE'],
- ['failure-threshold',
- 'failureThreshold',
- 'FAILURE']]
- supported_threshold_values = ['never',
- hudson_model.SUCCESS['name'],
- hudson_model.UNSTABLE['name'],
- hudson_model.FAILURE['name']]
- thrsh = project_def.get('block-thresholds', False)
+ block = XML.SubElement(tconfig, "block")
+ supported_thresholds = [
+ [
+ "build-step-failure-threshold",
+ "buildStepFailureThreshold",
+ "FAILURE",
+ ],
+ ["unstable-threshold", "unstableThreshold", "UNSTABLE"],
+ ["failure-threshold", "failureThreshold", "FAILURE"],
+ ]
+ supported_threshold_values = [
+ "never",
+ hudson_model.SUCCESS["name"],
+ hudson_model.UNSTABLE["name"],
+ hudson_model.FAILURE["name"],
+ ]
+ thrsh = project_def.get("block-thresholds", False)
for toptname, txmltag, tvalue in supported_thresholds:
if thrsh:
tvalue = thrsh.get(toptname, tvalue)
if tvalue.lower() == supported_threshold_values[0]:
continue
if tvalue.upper() not in supported_threshold_values:
- raise InvalidAttributeError(toptname,
- tvalue,
- supported_threshold_values)
+ raise InvalidAttributeError(
+ toptname, tvalue, supported_threshold_values
+ )
th = XML.SubElement(block, txmltag)
mapping = [
- ('name', 'name', None),
- ('ordinal', 'ordinal', None),
- ('color', 'color', None),
- ('', 'completeBuild', True),
+ ("name", "name", None),
+ ("ordinal", "ordinal", None),
+ ("color", "color", None),
+ ("", "completeBuild", True),
]
- helpers.convert_mapping_to_xml(th,
- hudson_model.THRESHOLDS[tvalue.upper()],
- mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(
+ th,
+ hudson_model.THRESHOLDS[tvalue.upper()],
+ mapping,
+ fail_required=True,
+ )
# If configs is empty, remove the entire tbuilder tree.
- if(len(configs) == 0):
+ if len(configs) == 0:
logger.debug("Pruning empty TriggerBuilder tree.")
xml_parent.remove(tbuilder)
@@ -782,11 +808,8 @@ def builders_from(registry, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/builders-from.yaml
:language: yaml
"""
- pbs = XML.SubElement(xml_parent,
- 'hudson.plugins.templateproject.ProxyBuilder')
- mapping = [
- ('', 'projectName', data),
- ]
+ pbs = XML.SubElement(xml_parent, "hudson.plugins.templateproject.ProxyBuilder")
+ mapping = [("", "projectName", data)]
helpers.convert_mapping_to_xml(pbs, {}, mapping, fail_required=True)
@@ -853,46 +876,46 @@ def http_request(registry, xml_parent, data):
:language: yaml
"""
- http_request = XML.SubElement(xml_parent,
- 'jenkins.plugins.http__request.HttpRequest')
- http_request.set('plugin', 'http_request')
-
- valid_modes = ['GET', 'POST', 'PUT', 'DELETE', 'HEAD']
- valid_types = ['NOT_SET', 'TEXT_HTML', 'APPLICATION_JSON',
- 'APPLICATION_TAR', 'APPLICATION_ZIP',
- 'APPLICATION_OCTETSTREAM']
+ http_request = XML.SubElement(
+ xml_parent, "jenkins.plugins.http__request.HttpRequest"
+ )
+ http_request.set("plugin", "http_request")
+
+ valid_modes = ["GET", "POST", "PUT", "DELETE", "HEAD"]
+ valid_types = [
+ "NOT_SET",
+ "TEXT_HTML",
+ "APPLICATION_JSON",
+ "APPLICATION_TAR",
+ "APPLICATION_ZIP",
+ "APPLICATION_OCTETSTREAM",
+ ]
mappings = [
- ('url', 'url', None),
- ('mode', 'httpMode', 'GET', valid_modes),
- ('content-type', 'contentType', 'NOT_SET', valid_types),
- ('accept-type', 'acceptType', 'NOT_SET', valid_types),
- ('output-file', 'outputFile', ''),
- ('console-log', 'consoleLogResponseBody', False),
- ('pass-build', 'passBuildParameters', False),
- ('time-out', 'timeout', 0),
- ('valid-response-codes', 'validResponseCodes', ''),
- ('valid-response-content', 'validResponseContent', ''),
+ ("url", "url", None),
+ ("mode", "httpMode", "GET", valid_modes),
+ ("content-type", "contentType", "NOT_SET", valid_types),
+ ("accept-type", "acceptType", "NOT_SET", valid_types),
+ ("output-file", "outputFile", ""),
+ ("console-log", "consoleLogResponseBody", False),
+ ("pass-build", "passBuildParameters", False),
+ ("time-out", "timeout", 0),
+ ("valid-response-codes", "validResponseCodes", ""),
+ ("valid-response-content", "validResponseContent", ""),
]
- helpers.convert_mapping_to_xml(
- http_request, data, mappings, fail_required=True)
+ helpers.convert_mapping_to_xml(http_request, data, mappings, fail_required=True)
- if 'authentication-key' in data:
- XML.SubElement(
- http_request, 'authentication').text = data['authentication-key']
+ if "authentication-key" in data:
+ XML.SubElement(http_request, "authentication").text = data["authentication-key"]
- if 'custom-headers' in data:
- customHeader = XML.SubElement(http_request, 'customHeaders')
- header_mappings = [
- ('name', 'name', None),
- ('value', 'value', None),
- ]
- for customhead in data['custom-headers']:
- pair = XML.SubElement(customHeader, 'pair')
- helpers.convert_mapping_to_xml(pair,
- customhead,
- header_mappings,
- fail_required=True)
+ if "custom-headers" in data:
+ customHeader = XML.SubElement(http_request, "customHeaders")
+ header_mappings = [("name", "name", None), ("value", "value", None)]
+ for customhead in data["custom-headers"]:
+ pair = XML.SubElement(customHeader, "pair")
+ helpers.convert_mapping_to_xml(
+ pair, customhead, header_mappings, fail_required=True
+ )
def inject(registry, xml_parent, data):
@@ -911,13 +934,13 @@ def inject(registry, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/inject.yaml
:language: yaml
"""
- eib = XML.SubElement(xml_parent, 'EnvInjectBuilder')
- info = XML.SubElement(eib, 'info')
+ eib = XML.SubElement(xml_parent, "EnvInjectBuilder")
+ info = XML.SubElement(eib, "info")
mapping = [
- ('properties-file', 'propertiesFilePath', None),
- ('properties-content', 'propertiesContent', None),
- ('script-file', 'scriptFilePath', None),
- ('script-content', 'scriptContent', None),
+ ("properties-file", "propertiesFilePath", None),
+ ("properties-content", "propertiesContent", None),
+ ("script-file", "scriptFilePath", None),
+ ("script-content", "scriptContent", None),
]
helpers.convert_mapping_to_xml(info, data, mapping, fail_required=False)
@@ -964,35 +987,35 @@ def kmap(registry, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/kmap-full.yaml
:language: yaml
"""
- kmap = XML.SubElement(
- xml_parent, 'org.jenkinsci.plugins.KmapJenkinsBuilder')
+ kmap = XML.SubElement(xml_parent, "org.jenkinsci.plugins.KmapJenkinsBuilder")
- kmap.set('plugin', 'kmap-jenkins')
- publish = data.get('publish-optional', False)
+ kmap.set("plugin", "kmap-jenkins")
+ publish = data.get("publish-optional", False)
mapping = [
- ('username', 'username', None),
- ('password', 'password', None),
- ('url', 'kmapClient', None),
- ('categories', 'categories', None),
- ('file-path', 'filePath', None),
- ('app-name', 'appName', None),
- ('bundle', 'bundle', ''),
- ('version', 'version', None),
- ('description', 'description', ''),
- ('icon-path', 'iconPath', ''),
+ ("username", "username", None),
+ ("password", "password", None),
+ ("url", "kmapClient", None),
+ ("categories", "categories", None),
+ ("file-path", "filePath", None),
+ ("app-name", "appName", None),
+ ("bundle", "bundle", ""),
+ ("version", "version", None),
+ ("description", "description", ""),
+ ("icon-path", "iconPath", ""),
]
helpers.convert_mapping_to_xml(kmap, data, mapping, fail_required=True)
if publish is True:
- publish_optional = XML.SubElement(kmap, 'publishOptional')
+ publish_optional = XML.SubElement(kmap, "publishOptional")
publish_mapping = [
- ('groups', 'teams', ''),
- ('users', 'users', ''),
- ('notify-users', 'sendNotifications', False),
+ ("groups", "teams", ""),
+ ("users", "users", ""),
+ ("notify-users", "sendNotifications", False),
]
helpers.convert_mapping_to_xml(
- publish_optional, data, publish_mapping, fail_required=True)
+ publish_optional, data, publish_mapping, fail_required=True
+ )
def artifact_resolver(registry, xml_parent, data):
@@ -1030,35 +1053,36 @@ def artifact_resolver(registry, xml_parent, data):
:language: yaml
"""
ar = XML.SubElement(
- xml_parent,
- 'org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver')
+ xml_parent, "org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver"
+ )
mapping = [
- ('target-directory', 'targetDirectory', None),
- ('fail-on-error', 'failOnError', False),
- ('repository-logging', 'enableRepoLogging', False),
- ('', 'snapshotUpdatePolicy', 'never'),
- ('', 'releaseUpdatePolicy', 'never'),
- ('', 'snapshotChecksumPolicy', 'warn'),
- ('', 'releaseChecksumPolicy', 'warn'),
+ ("target-directory", "targetDirectory", None),
+ ("fail-on-error", "failOnError", False),
+ ("repository-logging", "enableRepoLogging", False),
+ ("", "snapshotUpdatePolicy", "never"),
+ ("", "releaseUpdatePolicy", "never"),
+ ("", "snapshotChecksumPolicy", "warn"),
+ ("", "releaseChecksumPolicy", "warn"),
]
helpers.convert_mapping_to_xml(ar, data, mapping, fail_required=True)
- artifact_top = XML.SubElement(ar, 'artifacts')
- artifacts = data['artifacts']
+ artifact_top = XML.SubElement(ar, "artifacts")
+ artifacts = data["artifacts"]
artifacts_mapping = [
- ('group-id', 'groupId', None),
- ('artifact-id', 'artifactId', None),
- ('version', 'version', None),
- ('classifier', 'classifier', ''),
- ('extension', 'extension', 'jar'),
- ('target-file-name', 'targetFileName', ''),
+ ("group-id", "groupId", None),
+ ("artifact-id", "artifactId", None),
+ ("version", "version", None),
+ ("classifier", "classifier", ""),
+ ("extension", "extension", "jar"),
+ ("target-file-name", "targetFileName", ""),
]
for artifact in artifacts:
rcartifact = XML.SubElement(
- artifact_top,
- 'org.jvnet.hudson.plugins.repositoryconnector.Artifact')
+ artifact_top, "org.jvnet.hudson.plugins.repositoryconnector.Artifact"
+ )
helpers.convert_mapping_to_xml(
- rcartifact, artifact, artifacts_mapping, fail_required=True)
+ rcartifact, artifact, artifacts_mapping, fail_required=True
+ )
def doxygen(registry, xml_parent, data):
@@ -1079,13 +1103,12 @@ def doxygen(registry, xml_parent, data):
:language: yaml
"""
- doxygen = XML.SubElement(xml_parent,
- 'hudson.plugins.doxygen.DoxygenBuilder')
+ doxygen = XML.SubElement(xml_parent, "hudson.plugins.doxygen.DoxygenBuilder")
mappings = [
- ('doxyfile', 'doxyfilePath', None),
- ('install', 'installationName', None),
- ('ignore-failure', 'continueOnBuildFailure', False),
- ('unstable-warning', 'unstableIfWarnings', False),
+ ("doxyfile", "doxyfilePath", None),
+ ("install", "installationName", None),
+ ("ignore-failure", "continueOnBuildFailure", False),
+ ("unstable-warning", "unstableIfWarnings", False),
]
helpers.convert_mapping_to_xml(doxygen, data, mappings, fail_required=True)
@@ -1114,23 +1137,22 @@ def gradle(registry, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/gradle.yaml
:language: yaml
"""
- gradle = XML.SubElement(xml_parent, 'hudson.plugins.gradle.Gradle')
+ gradle = XML.SubElement(xml_parent, "hudson.plugins.gradle.Gradle")
- XML.SubElement(gradle, 'description').text = ''
+ XML.SubElement(gradle, "description").text = ""
mappings = [
- ('build-file', 'buildFile', 'build.gradle'),
- ('tasks', 'tasks', None),
- ('root-build-script-dir', 'rootBuildScriptDir', ''),
- ('gradle-name', 'gradleName', ''),
- ('wrapper', 'useWrapper', False),
- ('executable', 'makeExecutable', False),
- ('use-root-dir', 'fromRootBuildScriptDir', False),
+ ("build-file", "buildFile", "build.gradle"),
+ ("tasks", "tasks", None),
+ ("root-build-script-dir", "rootBuildScriptDir", ""),
+ ("gradle-name", "gradleName", ""),
+ ("wrapper", "useWrapper", False),
+ ("executable", "makeExecutable", False),
+ ("use-root-dir", "fromRootBuildScriptDir", False),
]
helpers.convert_mapping_to_xml(gradle, data, mappings, fail_required=True)
- XML.SubElement(gradle, 'switches').text = '\n'.join(
- data.get('switches', []))
+ XML.SubElement(gradle, "switches").text = "\n".join(data.get("switches", []))
def _groovy_common_scriptSource(data):
@@ -1138,23 +1160,17 @@ def _groovy_common_scriptSource(data):
"""
scriptSource = XML.Element("scriptSource")
- if 'command' in data and 'file' in data:
+ if "command" in data and "file" in data:
raise JenkinsJobsException("Use just one of 'command' or 'file'")
- if 'command' in data:
- mapping = [
- ('command', 'command', None),
- ]
- helpers.convert_mapping_to_xml(
- scriptSource, data, mapping, fail_required=True)
- scriptSource.set('class', 'hudson.plugins.groovy.StringScriptSource')
- elif 'file' in data:
- mapping = [
- ('file', 'scriptFile', None),
- ]
- helpers.convert_mapping_to_xml(
- scriptSource, data, mapping, fail_required=True)
- scriptSource.set('class', 'hudson.plugins.groovy.FileScriptSource')
+ if "command" in data:
+ mapping = [("command", "command", None)]
+ helpers.convert_mapping_to_xml(scriptSource, data, mapping, fail_required=True)
+ scriptSource.set("class", "hudson.plugins.groovy.StringScriptSource")
+ elif "file" in data:
+ mapping = [("file", "scriptFile", None)]
+ helpers.convert_mapping_to_xml(scriptSource, data, mapping, fail_required=True)
+ scriptSource.set("class", "hudson.plugins.groovy.FileScriptSource")
else:
raise JenkinsJobsException("A groovy command or file is required")
@@ -1195,17 +1211,17 @@ def groovy(registry, xml_parent, data):
:language: yaml
"""
- root_tag = 'hudson.plugins.groovy.Groovy'
+ root_tag = "hudson.plugins.groovy.Groovy"
groovy = XML.SubElement(xml_parent, root_tag)
groovy.append(_groovy_common_scriptSource(data))
mappings = [
- ('version', 'groovyName', '(Default)'),
- ('parameters', 'parameters', ''),
- ('script-parameters', 'scriptParameters', ''),
- ('properties', 'properties', ''),
- ('java-opts', 'javaOpts', ''),
- ('class-path', 'classPath', ''),
+ ("version", "groovyName", "(Default)"),
+ ("parameters", "parameters", ""),
+ ("script-parameters", "scriptParameters", ""),
+ ("properties", "properties", ""),
+ ("java-opts", "javaOpts", ""),
+ ("class-path", "classPath", ""),
]
helpers.convert_mapping_to_xml(groovy, data, mappings, fail_required=True)
@@ -1233,16 +1249,12 @@ def system_groovy(registry, xml_parent, data):
:language: yaml
"""
- root_tag = 'hudson.plugins.groovy.SystemGroovy'
+ root_tag = "hudson.plugins.groovy.SystemGroovy"
sysgroovy = XML.SubElement(xml_parent, root_tag)
sysgroovy.append(_groovy_common_scriptSource(data))
- mapping = [
- ('bindings', 'bindings', ''),
- ('class-path', 'classpath', ''),
- ]
- helpers.convert_mapping_to_xml(
- sysgroovy, data, mapping, fail_required=True)
+ mapping = [("bindings", "bindings", ""), ("class-path", "classpath", "")]
+ helpers.convert_mapping_to_xml(sysgroovy, data, mapping, fail_required=True)
def batch(registry, xml_parent, data):
@@ -1256,8 +1268,8 @@ def batch(registry, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/batch.yaml
:language: yaml
"""
- batch = XML.SubElement(xml_parent, 'hudson.tasks.BatchFile')
- XML.SubElement(batch, 'command').text = data
+ batch = XML.SubElement(xml_parent, "hudson.tasks.BatchFile")
+ XML.SubElement(batch, "command").text = data
def powershell(registry, xml_parent, data):
@@ -1272,8 +1284,8 @@ def powershell(registry, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/powershell.yaml
:language: yaml
"""
- ps = XML.SubElement(xml_parent, 'hudson.plugins.powershell.PowerShell')
- XML.SubElement(ps, 'command').text = data
+ ps = XML.SubElement(xml_parent, "hudson.plugins.powershell.PowerShell")
+ XML.SubElement(ps, "command").text = data
def msbuild(registry, xml_parent, data):
@@ -1302,25 +1314,23 @@ def msbuild(registry, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/msbuild-minimal.yaml
:language: yaml
"""
- msbuilder = XML.SubElement(xml_parent,
- 'hudson.plugins.msbuild.MsBuildBuilder')
- msbuilder.set('plugin', 'msbuild')
+ msbuilder = XML.SubElement(xml_parent, "hudson.plugins.msbuild.MsBuildBuilder")
+ msbuilder.set("plugin", "msbuild")
mapping = [
- ('msbuild-version', 'msBuildName', '(Default)'),
- ('solution-file', 'msBuildFile', None),
- ('extra-parameters', 'cmdLineArgs', ''),
- ('pass-build-variables', 'buildVariablesAsProperties', True),
- ('continue-on-build-failure', 'continueOnBuildFailure', False),
- ('unstable-if-warnings', 'unstableIfWarnings', False),
+ ("msbuild-version", "msBuildName", "(Default)"),
+ ("solution-file", "msBuildFile", None),
+ ("extra-parameters", "cmdLineArgs", ""),
+ ("pass-build-variables", "buildVariablesAsProperties", True),
+ ("continue-on-build-failure", "continueOnBuildFailure", False),
+ ("unstable-if-warnings", "unstableIfWarnings", False),
]
- helpers.convert_mapping_to_xml(
- msbuilder, data, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(msbuilder, data, mapping, fail_required=True)
def create_builders(registry, step):
dummy_parent = XML.Element("dummy")
- registry.dispatch('builder', dummy_parent, step)
+ registry.dispatch("builder", dummy_parent, step)
return list(dummy_parent)
@@ -1532,239 +1542,234 @@ def conditional_step(registry, xml_parent, data):
/../../tests/builders/fixtures/conditional-step-and.yaml
:language: yaml
"""
+
def build_condition(cdata, cond_root_tag, condition_tag):
- kind = cdata['condition-kind']
+ kind = cdata["condition-kind"]
ctag = XML.SubElement(cond_root_tag, condition_tag)
- core_prefix = 'org.jenkins_ci.plugins.run_condition.core.'
- logic_prefix = 'org.jenkins_ci.plugins.run_condition.logic.'
+ core_prefix = "org.jenkins_ci.plugins.run_condition.core."
+ logic_prefix = "org.jenkins_ci.plugins.run_condition.logic."
if kind == "always":
- ctag.set('class', core_prefix + 'AlwaysRun')
+ ctag.set("class", core_prefix + "AlwaysRun")
elif kind == "never":
- ctag.set('class', core_prefix + 'NeverRun')
+ ctag.set("class", core_prefix + "NeverRun")
elif kind == "boolean-expression":
- ctag.set('class', core_prefix + 'BooleanCondition')
- mapping = [
- ('condition-expression', 'token', None),
- ]
- helpers.convert_mapping_to_xml(
- ctag, cdata, mapping, fail_required=True)
+ ctag.set("class", core_prefix + "BooleanCondition")
+ mapping = [("condition-expression", "token", None)]
+ helpers.convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True)
elif kind == "build-cause":
- ctag.set('class', core_prefix + 'CauseCondition')
- cause_list = ('USER_CAUSE', 'SCM_CAUSE', 'TIMER_CAUSE',
- 'CLI_CAUSE', 'REMOTE_CAUSE', 'UPSTREAM_CAUSE',
- 'FS_CAUSE', 'URL_CAUSE', 'IVY_CAUSE',
- 'SCRIPT_CAUSE', 'BUILDRESULT_CAUSE')
+ ctag.set("class", core_prefix + "CauseCondition")
+ cause_list = (
+ "USER_CAUSE",
+ "SCM_CAUSE",
+ "TIMER_CAUSE",
+ "CLI_CAUSE",
+ "REMOTE_CAUSE",
+ "UPSTREAM_CAUSE",
+ "FS_CAUSE",
+ "URL_CAUSE",
+ "IVY_CAUSE",
+ "SCRIPT_CAUSE",
+ "BUILDRESULT_CAUSE",
+ )
mapping = [
- ('cause', 'buildCause', 'USER_CAUSE', cause_list),
- ('exclusive-cause', "exclusiveCause", False),
+ ("cause", "buildCause", "USER_CAUSE", cause_list),
+ ("exclusive-cause", "exclusiveCause", False),
]
- helpers.convert_mapping_to_xml(
- ctag, cdata, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True)
elif kind == "day-of-week":
- ctag.set('class', core_prefix + 'DayCondition')
- day_selector_class_prefix = core_prefix + 'DayCondition$'
+ ctag.set("class", core_prefix + "DayCondition")
+ day_selector_class_prefix = core_prefix + "DayCondition$"
day_selector_classes = {
- 'weekend': day_selector_class_prefix + 'Weekend',
- 'weekday': day_selector_class_prefix + 'Weekday',
- 'select-days': day_selector_class_prefix + 'SelectDays',
+ "weekend": day_selector_class_prefix + "Weekend",
+ "weekday": day_selector_class_prefix + "Weekday",
+ "select-days": day_selector_class_prefix + "SelectDays",
}
- day_selector = cdata.get('day-selector', 'weekend')
+ day_selector = cdata.get("day-selector", "weekend")
if day_selector not in day_selector_classes:
- raise InvalidAttributeError('day-selector', day_selector,
- day_selector_classes)
+ raise InvalidAttributeError(
+ "day-selector", day_selector, day_selector_classes
+ )
day_selector_tag = XML.SubElement(ctag, "daySelector")
- day_selector_tag.set('class', day_selector_classes[day_selector])
+ day_selector_tag.set("class", day_selector_classes[day_selector])
if day_selector == "select-days":
days_tag = XML.SubElement(day_selector_tag, "days")
- day_tag_text = ('org.jenkins__ci.plugins.run__condition.'
- 'core.DayCondition_-Day')
- inp_days = cdata.get('days') if cdata.get('days') else {}
- days = ['SUN', 'MON', 'TUES', 'WED', 'THURS', 'FRI', 'SAT']
+ day_tag_text = (
+ "org.jenkins__ci.plugins.run__condition." "core.DayCondition_-Day"
+ )
+ inp_days = cdata.get("days") if cdata.get("days") else {}
+ days = ["SUN", "MON", "TUES", "WED", "THURS", "FRI", "SAT"]
for day_no, day in enumerate(days, 1):
day_tag = XML.SubElement(days_tag, day_tag_text)
- mapping = [
- ('', 'day', day_no),
- (day, "selected", False),
- ]
- helpers.convert_mapping_to_xml(day_tag,
- inp_days, mapping, fail_required=True)
- mapping = [
- ('use-build-time', "useBuildTime", False),
- ]
- helpers.convert_mapping_to_xml(
- ctag, cdata, mapping, fail_required=True)
+ mapping = [("", "day", day_no), (day, "selected", False)]
+ helpers.convert_mapping_to_xml(
+ day_tag, inp_days, mapping, fail_required=True
+ )
+ mapping = [("use-build-time", "useBuildTime", False)]
+ helpers.convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True)
elif kind == "execution-node":
- ctag.set('class', core_prefix + 'NodeCondition')
+ ctag.set("class", core_prefix + "NodeCondition")
allowed_nodes_tag = XML.SubElement(ctag, "allowedNodes")
- for node in cdata['nodes']:
- mapping = [
- ('', "string", node),
- ]
- helpers.convert_mapping_to_xml(allowed_nodes_tag,
- cdata, mapping, fail_required=True)
+ for node in cdata["nodes"]:
+ mapping = [("", "string", node)]
+ helpers.convert_mapping_to_xml(
+ allowed_nodes_tag, cdata, mapping, fail_required=True
+ )
elif kind == "strings-match":
- ctag.set('class', core_prefix + 'StringsMatchCondition')
+ ctag.set("class", core_prefix + "StringsMatchCondition")
mapping = [
- ('condition-string1', "arg1", ''),
- ('condition-string2', "arg2", ''),
- ('condition-case-insensitive', "ignoreCase", False),
+ ("condition-string1", "arg1", ""),
+ ("condition-string2", "arg2", ""),
+ ("condition-case-insensitive", "ignoreCase", False),
]
- helpers.convert_mapping_to_xml(
- ctag, cdata, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True)
elif kind == "current-status":
- ctag.set('class', core_prefix + 'StatusCondition')
- wr = XML.SubElement(ctag, 'worstResult')
- wr_name = cdata.get('condition-worst', 'SUCCESS')
+ ctag.set("class", core_prefix + "StatusCondition")
+ wr = XML.SubElement(ctag, "worstResult")
+ wr_name = cdata.get("condition-worst", "SUCCESS")
if wr_name not in hudson_model.THRESHOLDS:
- raise InvalidAttributeError('condition-worst', wr_name,
- hudson_model.THRESHOLDS.keys())
+ raise InvalidAttributeError(
+ "condition-worst", wr_name, hudson_model.THRESHOLDS.keys()
+ )
wr_threshold = hudson_model.THRESHOLDS[wr_name]
mapping = [
- ('name', 'name', None),
- ('ordinal', 'ordinal', None),
- ('color', 'color', 'color'),
- ('complete', 'completeBuild', None),
+ ("name", "name", None),
+ ("ordinal", "ordinal", None),
+ ("color", "color", "color"),
+ ("complete", "completeBuild", None),
]
- helpers.convert_mapping_to_xml(wr,
- wr_threshold, mapping, fail_required=True)
- br = XML.SubElement(ctag, 'bestResult')
- br_name = cdata.get('condition-best', 'SUCCESS')
+ helpers.convert_mapping_to_xml(
+ wr, wr_threshold, mapping, fail_required=True
+ )
+ br = XML.SubElement(ctag, "bestResult")
+ br_name = cdata.get("condition-best", "SUCCESS")
if br_name not in hudson_model.THRESHOLDS:
- raise InvalidAttributeError('condition-best', br_name,
- hudson_model.THRESHOLDS.keys())
+ raise InvalidAttributeError(
+ "condition-best", br_name, hudson_model.THRESHOLDS.keys()
+ )
br_threshold = hudson_model.THRESHOLDS[br_name]
mapping = [
- ('name', 'name', None),
- ('ordinal', 'ordinal', None),
- ('color', 'color', 'color'),
- ('complete', 'completeBuild', None),
- ]
- helpers.convert_mapping_to_xml(br,
- br_threshold, mapping, fail_required=True)
- elif kind == "shell":
- ctag.set('class',
- 'org.jenkins_ci.plugins.run_condition.contributed.'
- 'ShellCondition')
- mapping = [
- ('condition-command', 'command', ''),
+ ("name", "name", None),
+ ("ordinal", "ordinal", None),
+ ("color", "color", "color"),
+ ("complete", "completeBuild", None),
]
helpers.convert_mapping_to_xml(
- ctag, cdata, mapping, fail_required=True)
+ br, br_threshold, mapping, fail_required=True
+ )
+ elif kind == "shell":
+ ctag.set(
+ "class",
+ "org.jenkins_ci.plugins.run_condition.contributed." "ShellCondition",
+ )
+ mapping = [("condition-command", "command", "")]
+ helpers.convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True)
elif kind == "windows-shell":
- ctag.set('class',
- 'org.jenkins_ci.plugins.run_condition.contributed.'
- 'BatchFileCondition')
- mapping = [
- ('condition-command', 'command', ''),
- ]
- helpers.convert_mapping_to_xml(
- ctag, cdata, mapping, fail_required=True)
+ ctag.set(
+ "class",
+ "org.jenkins_ci.plugins.run_condition.contributed."
+ "BatchFileCondition",
+ )
+ mapping = [("condition-command", "command", "")]
+ helpers.convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True)
elif kind == "file-exists" or kind == "files-match":
if kind == "file-exists":
- ctag.set('class', core_prefix + 'FileExistsCondition')
- mapping = [
- ('condition-filename', 'file', None),
- ]
- helpers.convert_mapping_to_xml(ctag, cdata, mapping,
- fail_required=True)
+ ctag.set("class", core_prefix + "FileExistsCondition")
+ mapping = [("condition-filename", "file", None)]
+ helpers.convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True)
else:
- ctag.set('class', core_prefix + 'FilesMatchCondition')
- XML.SubElement(ctag, "includes").text = ",".join(cdata.get(
- 'include-pattern', ''))
- XML.SubElement(ctag, "excludes").text = ",".join(cdata.get(
- 'exclude-pattern', ''))
- basedir_class_prefix = ('org.jenkins_ci.plugins.run_condition.'
- 'common.BaseDirectory$')
+ ctag.set("class", core_prefix + "FilesMatchCondition")
+ XML.SubElement(ctag, "includes").text = ",".join(
+ cdata.get("include-pattern", "")
+ )
+ XML.SubElement(ctag, "excludes").text = ",".join(
+ cdata.get("exclude-pattern", "")
+ )
+ basedir_class_prefix = (
+ "org.jenkins_ci.plugins.run_condition." "common.BaseDirectory$"
+ )
basedir_classes = {
- 'workspace': basedir_class_prefix + 'Workspace',
- 'artifact-directory': basedir_class_prefix + 'ArtifactsDir',
- 'jenkins-home': basedir_class_prefix + 'JenkinsHome'
+ "workspace": basedir_class_prefix + "Workspace",
+ "artifact-directory": basedir_class_prefix + "ArtifactsDir",
+ "jenkins-home": basedir_class_prefix + "JenkinsHome",
}
- basedir = cdata.get('condition-basedir', 'workspace')
+ basedir = cdata.get("condition-basedir", "workspace")
if basedir not in basedir_classes:
- raise InvalidAttributeError('condition-basedir', basedir,
- basedir_classes)
- XML.SubElement(ctag, "baseDir").set('class',
- basedir_classes[basedir])
+ raise InvalidAttributeError(
+ "condition-basedir", basedir, basedir_classes
+ )
+ XML.SubElement(ctag, "baseDir").set("class", basedir_classes[basedir])
elif kind == "num-comp":
- ctag.set('class', core_prefix + 'NumericalComparisonCondition')
- mapping = [
- ('lhs', 'lhs', None),
- ('rhs', 'rhs', None),
- ]
- helpers.convert_mapping_to_xml(
- ctag, cdata, mapping, fail_required=True)
- comp_class_prefix = core_prefix + 'NumericalComparisonCondition$'
+ ctag.set("class", core_prefix + "NumericalComparisonCondition")
+ mapping = [("lhs", "lhs", None), ("rhs", "rhs", None)]
+ helpers.convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True)
+ comp_class_prefix = core_prefix + "NumericalComparisonCondition$"
comp_classes = {
- 'less-than': comp_class_prefix + 'LessThan',
- 'greater-than': comp_class_prefix + 'GreaterThan',
- 'equal': comp_class_prefix + 'EqualTo',
- 'not-equal': comp_class_prefix + 'NotEqualTo',
- 'less-than-equal': comp_class_prefix + 'LessThanOrEqualTo',
- 'greater-than-equal': comp_class_prefix +
- 'GreaterThanOrEqualTo'
+ "less-than": comp_class_prefix + "LessThan",
+ "greater-than": comp_class_prefix + "GreaterThan",
+ "equal": comp_class_prefix + "EqualTo",
+ "not-equal": comp_class_prefix + "NotEqualTo",
+ "less-than-equal": comp_class_prefix + "LessThanOrEqualTo",
+ "greater-than-equal": comp_class_prefix + "GreaterThanOrEqualTo",
}
- comp = cdata.get('comparator', 'less-than')
+ comp = cdata.get("comparator", "less-than")
if comp not in comp_classes:
- raise InvalidAttributeError('comparator', comp, comp_classes)
- XML.SubElement(ctag, "comparator").set('class',
- comp_classes[comp])
+ raise InvalidAttributeError("comparator", comp, comp_classes)
+ XML.SubElement(ctag, "comparator").set("class", comp_classes[comp])
elif kind == "regex-match":
- ctag.set('class', core_prefix + 'ExpressionCondition')
- mapping = [
- ('regex', 'expression', ''),
- ('label', 'label', ''),
- ]
- helpers.convert_mapping_to_xml(
- ctag, cdata, mapping, fail_required=True)
+ ctag.set("class", core_prefix + "ExpressionCondition")
+ mapping = [("regex", "expression", ""), ("label", "label", "")]
+ helpers.convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True)
elif kind == "time":
- ctag.set('class', core_prefix + 'TimeCondition')
+ ctag.set("class", core_prefix + "TimeCondition")
mapping = [
- ('earliest-hour', 'earliestHours', '09'),
- ('earliest-min', 'earliestMinutes', '00'),
- ('latest-hour', 'latestHours', '17'),
- ('latest-min', 'latestMinutes', '30'),
- ('use-build-time', 'useBuildTime', False),
+ ("earliest-hour", "earliestHours", "09"),
+ ("earliest-min", "earliestMinutes", "00"),
+ ("latest-hour", "latestHours", "17"),
+ ("latest-min", "latestMinutes", "30"),
+ ("use-build-time", "useBuildTime", False),
]
- helpers.convert_mapping_to_xml(
- ctag, cdata, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(ctag, cdata, mapping, fail_required=True)
elif kind == "not":
- ctag.set('class', logic_prefix + 'Not')
+ ctag.set("class", logic_prefix + "Not")
try:
- notcondition = cdata['condition-operand']
+ notcondition = cdata["condition-operand"]
except KeyError:
- raise MissingAttributeError('condition-operand')
+ raise MissingAttributeError("condition-operand")
build_condition(notcondition, ctag, "condition")
elif kind == "and" or "or":
if kind == "and":
- ctag.set('class', logic_prefix + 'And')
+ ctag.set("class", logic_prefix + "And")
else:
- ctag.set('class', logic_prefix + 'Or')
+ ctag.set("class", logic_prefix + "Or")
conditions_tag = XML.SubElement(ctag, "conditions")
- container_tag_text = ('org.jenkins__ci.plugins.run__condition.'
- 'logic.ConditionContainer')
+ container_tag_text = (
+ "org.jenkins__ci.plugins.run__condition." "logic.ConditionContainer"
+ )
try:
- conditions_list = cdata['condition-operands']
+ conditions_list = cdata["condition-operands"]
except KeyError:
- raise MissingAttributeError('condition-operands')
+ raise MissingAttributeError("condition-operands")
for condition in conditions_list:
- conditions_container_tag = XML.SubElement(conditions_tag,
- container_tag_text)
- build_condition(condition, conditions_container_tag,
- "condition")
+ conditions_container_tag = XML.SubElement(
+ conditions_tag, container_tag_text
+ )
+ build_condition(condition, conditions_container_tag, "condition")
def build_step(parent, step):
for edited_node in create_builders(registry, step):
if not has_multiple_steps:
- edited_node.set('class', edited_node.tag)
- edited_node.tag = 'buildStep'
+ edited_node.set("class", edited_node.tag)
+ edited_node.tag = "buildStep"
parent.append(edited_node)
- cond_builder_tag = ('org.jenkinsci.plugins.conditionalbuildstep.'
- 'singlestep.SingleConditionalBuilder')
- cond_builders_tag = ('org.jenkinsci.plugins.conditionalbuildstep.'
- 'ConditionalBuilder')
- steps = data['steps']
+ cond_builder_tag = (
+ "org.jenkinsci.plugins.conditionalbuildstep."
+ "singlestep.SingleConditionalBuilder"
+ )
+ cond_builders_tag = (
+ "org.jenkinsci.plugins.conditionalbuildstep." "ConditionalBuilder"
+ )
+ steps = data["steps"]
has_multiple_steps = len(steps) > 1
if has_multiple_steps:
@@ -1777,19 +1782,17 @@ def conditional_step(registry, xml_parent, data):
condition_tag = "condition"
build_condition(data, root_tag, condition_tag)
- evaluation_classes_pkg = 'org.jenkins_ci.plugins.run_condition'
+ evaluation_classes_pkg = "org.jenkins_ci.plugins.run_condition"
evaluation_classes = {
- 'fail': evaluation_classes_pkg + '.BuildStepRunner$Fail',
- 'mark-unstable': evaluation_classes_pkg + '.BuildStepRunner$Unstable',
- 'run-and-mark-unstable': evaluation_classes_pkg +
- '.BuildStepRunner$RunUnstable',
- 'run': evaluation_classes_pkg + '.BuildStepRunner$Run',
- 'dont-run': evaluation_classes_pkg + '.BuildStepRunner$DontRun',
+ "fail": evaluation_classes_pkg + ".BuildStepRunner$Fail",
+ "mark-unstable": evaluation_classes_pkg + ".BuildStepRunner$Unstable",
+ "run-and-mark-unstable": evaluation_classes_pkg
+ + ".BuildStepRunner$RunUnstable",
+ "run": evaluation_classes_pkg + ".BuildStepRunner$Run",
+ "dont-run": evaluation_classes_pkg + ".BuildStepRunner$DontRun",
}
- evaluation_class = evaluation_classes[data.get('on-evaluation-failure',
- 'fail')]
- XML.SubElement(root_tag, "runner").set('class',
- evaluation_class)
+ evaluation_class = evaluation_classes[data.get("on-evaluation-failure", "fail")]
+ XML.SubElement(root_tag, "runner").set("class", evaluation_class)
for step in steps:
build_step(steps_parent, step)
@@ -1813,13 +1816,13 @@ def maven_builder(registry, xml_parent, data):
.. literalinclude:: /../../tests/builders/fixtures/maven-builder001.yaml
:language: yaml
"""
- maven = XML.SubElement(xml_parent, 'org.jfrog.hudson.maven3.Maven3Builder')
+ maven = XML.SubElement(xml_parent, "org.jfrog.hudson.maven3.Maven3Builder")
mapping = [
- ('name', 'mavenName', None),
- ('goals', 'goals', None),
- ('pom', 'rootPom', 'pom.xml'),
- ('maven-opts', 'mavenOpts', ''),
+ ("name", "mavenName", None),
+ ("goals", "goals", None),
+ ("pom", "rootPom", "pom.xml"),
+ ("maven-opts", "mavenOpts", ""),
]
helpers.convert_mapping_to_xml(maven, data, mapping, fail_required=True)
@@ -1859,25 +1862,25 @@ def jira_issue_updater(registry, xml_parent, data):
/../../tests/builders/fixtures/jenkins-jira-issue-updater-full.yaml
:language: yaml
"""
- issue_updater = XML.SubElement(xml_parent, 'info.bluefloyd.jenkins.'
- 'IssueUpdatesBuilder')
- issue_updater.set('plugin', 'jenkins-jira-issue-updater')
+ issue_updater = XML.SubElement(
+ xml_parent, "info.bluefloyd.jenkins." "IssueUpdatesBuilder"
+ )
+ issue_updater.set("plugin", "jenkins-jira-issue-updater")
mapping = [
- ('base-url', 'restAPIUrl', ''),
- ('username', 'userName', None),
- ('password', 'password', None),
- ('jql', 'jql', None),
- ('workflow', 'workflowActionName', ''),
- ('comment', 'comment', ''),
- ('custom-Id', 'customFieldId', ''),
- ('custom-value', 'customFieldValue', ''),
- ('fail-if-error', 'failIfJqlFails', False),
- ('fail-if-no-match', 'failIfNoIssuesReturned', False),
- ('fail-if-no-connection', 'failIfNoJiraConnection', False),
+ ("base-url", "restAPIUrl", ""),
+ ("username", "userName", None),
+ ("password", "password", None),
+ ("jql", "jql", None),
+ ("workflow", "workflowActionName", ""),
+ ("comment", "comment", ""),
+ ("custom-Id", "customFieldId", ""),
+ ("custom-value", "customFieldValue", ""),
+ ("fail-if-error", "failIfJqlFails", False),
+ ("fail-if-no-match", "failIfNoIssuesReturned", False),
+ ("fail-if-no-connection", "failIfNoJiraConnection", False),
]
- helpers.convert_mapping_to_xml(
- issue_updater, data, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(issue_updater, data, mapping, fail_required=True)
def maven_target(registry, xml_parent, data):
@@ -1917,20 +1920,20 @@ def maven_target(registry, xml_parent, data):
.. literalinclude:: /../../tests/builders/fixtures/maven-target002.yaml
:language: yaml
"""
- maven = XML.SubElement(xml_parent, 'hudson.tasks.Maven')
- XML.SubElement(maven, 'targets').text = data['goals']
- prop_string = '\n'.join(data.get('properties', []))
- XML.SubElement(maven, 'properties').text = prop_string
+ maven = XML.SubElement(xml_parent, "hudson.tasks.Maven")
+ XML.SubElement(maven, "targets").text = data["goals"]
+ prop_string = "\n".join(data.get("properties", []))
+ XML.SubElement(maven, "properties").text = prop_string
mapping = [
- ('maven-version', 'mavenName', None),
- ('pom', 'pom', None),
- ('private-repository', 'usePrivateRepository', False),
+ ("maven-version", "mavenName", None),
+ ("pom", "pom", None),
+ ("private-repository", "usePrivateRepository", False),
]
helpers.convert_mapping_to_xml(maven, data, mapping, fail_required=False)
- if 'java-opts' in data:
- javaoptions = ' '.join(data.get('java-opts', []))
- XML.SubElement(maven, 'jvmOptions').text = javaoptions
+ if "java-opts" in data:
+ javaoptions = " ".join(data.get("java-opts", []))
+ XML.SubElement(maven, "jvmOptions").text = javaoptions
helpers.config_file_provider_settings(maven, data)
@@ -1995,143 +1998,132 @@ def multijob(registry, xml_parent, data):
.. literalinclude:: /../../tests/builders/fixtures/multibuild.yaml
:language: yaml
"""
- builder = XML.SubElement(xml_parent, 'com.tikal.jenkins.plugins.multijob.'
- 'MultiJobBuilder')
- conditions_available = ('SUCCESSFUL', 'UNSTABLE', 'COMPLETED', 'FAILURE',
- 'ALWAYS')
- job_execution_type_available = ('PARALLEL', 'SEQUENTIALLY')
+ builder = XML.SubElement(
+ xml_parent, "com.tikal.jenkins.plugins.multijob." "MultiJobBuilder"
+ )
+ conditions_available = ("SUCCESSFUL", "UNSTABLE", "COMPLETED", "FAILURE", "ALWAYS")
+ job_execution_type_available = ("PARALLEL", "SEQUENTIALLY")
mapping = [
- ('name', 'phaseName', None),
- ('condition', 'continuationCondition',
- 'SUCCESSFUL', conditions_available),
- ('execution-type', 'executionType',
- 'PARALLEL', job_execution_type_available),
+ ("name", "phaseName", None),
+ ("condition", "continuationCondition", "SUCCESSFUL", conditions_available),
+ ("execution-type", "executionType", "PARALLEL", job_execution_type_available),
]
helpers.convert_mapping_to_xml(builder, data, mapping, fail_required=True)
- phaseJobs = XML.SubElement(builder, 'phaseJobs')
+ phaseJobs = XML.SubElement(builder, "phaseJobs")
- kill_status_list = ('FAILURE', 'UNSTABLE', 'NEVER')
+ kill_status_list = ("FAILURE", "UNSTABLE", "NEVER")
- for project in data.get('projects', []):
- phaseJob = XML.SubElement(phaseJobs, 'com.tikal.jenkins.plugins.'
- 'multijob.PhaseJobsConfig')
+ for project in data.get("projects", []):
+ phaseJob = XML.SubElement(
+ phaseJobs, "com.tikal.jenkins.plugins." "multijob.PhaseJobsConfig"
+ )
mapping = [
- ('name', 'jobName', None),
+ ("name", "jobName", None),
# Pass through the current build params
- ('current-parameters', 'currParams', False),
+ ("current-parameters", "currParams", False),
]
- helpers.convert_mapping_to_xml(
- phaseJob, project, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(phaseJob, project, mapping, fail_required=True)
# Pass through other params
- configs = XML.SubElement(phaseJob, 'configs')
+ configs = XML.SubElement(phaseJob, "configs")
- nodeLabelName = project.get('node-label-name')
- nodeLabel = project.get('node-label')
+ nodeLabelName = project.get("node-label-name")
+ nodeLabel = project.get("node-label")
if nodeLabelName and nodeLabel:
node = XML.SubElement(
- configs, 'org.jvnet.jenkins.plugins.nodelabelparameter.'
- 'parameterizedtrigger.NodeLabelBuildParameter')
- mapping = [
- ('', 'name', nodeLabelName),
- ('', 'nodeLabel', nodeLabel),
- ]
- helpers.convert_mapping_to_xml(
- node, project, mapping, fail_required=True)
+ configs,
+ "org.jvnet.jenkins.plugins.nodelabelparameter."
+ "parameterizedtrigger.NodeLabelBuildParameter",
+ )
+ mapping = [("", "name", nodeLabelName), ("", "nodeLabel", nodeLabel)]
+ helpers.convert_mapping_to_xml(node, project, mapping, fail_required=True)
# Node parameter
- if project.get('node-parameters', False):
- XML.SubElement(configs, 'hudson.plugins.parameterizedtrigger.'
- 'NodeParameters')
+ if project.get("node-parameters", False):
+ XML.SubElement(
+ configs, "hudson.plugins.parameterizedtrigger." "NodeParameters"
+ )
# Git Revision
- if project.get('git-revision', False):
- param = XML.SubElement(configs,
- 'hudson.plugins.git.'
- 'GitRevisionBuildParameters')
- mapping = [
- ('', 'combineQueuedCommits', False),
- ]
- helpers.convert_mapping_to_xml(
- param, project, mapping, fail_required=True)
+ if project.get("git-revision", False):
+ param = XML.SubElement(
+ configs, "hudson.plugins.git." "GitRevisionBuildParameters"
+ )
+ mapping = [("", "combineQueuedCommits", False)]
+ helpers.convert_mapping_to_xml(param, project, mapping, fail_required=True)
# Properties File
- properties_file = project.get('property-file', False)
+ properties_file = project.get("property-file", False)
if properties_file:
- param = XML.SubElement(configs,
- 'hudson.plugins.parameterizedtrigger.'
- 'FileBuildParameters')
+ param = XML.SubElement(
+ configs, "hudson.plugins.parameterizedtrigger." "FileBuildParameters"
+ )
mapping = [
- ('', 'propertiesFile', properties_file),
- ('', 'failTriggerOnMissing', True),
+ ("", "propertiesFile", properties_file),
+ ("", "failTriggerOnMissing", True),
]
- helpers.convert_mapping_to_xml(
- param, project, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(param, project, mapping, fail_required=True)
# Predefined Parameters
- predefined_parameters = project.get('predefined-parameters', False)
+ predefined_parameters = project.get("predefined-parameters", False)
if predefined_parameters:
- param = XML.SubElement(configs,
- 'hudson.plugins.parameterizedtrigger.'
- 'PredefinedBuildParameters')
- mapping = [
- ('', 'properties', predefined_parameters),
- ]
- helpers.convert_mapping_to_xml(
- param, project, mapping, fail_required=True)
+ param = XML.SubElement(
+ configs,
+ "hudson.plugins.parameterizedtrigger." "PredefinedBuildParameters",
+ )
+ mapping = [("", "properties", predefined_parameters)]
+ helpers.convert_mapping_to_xml(param, project, mapping, fail_required=True)
mapping = [
- ('abort-all-job', 'abortAllJob', False),
- ('aggregate-results', 'aggregatedTestResults', False),
+ ("abort-all-job", "abortAllJob", False),
+ ("aggregate-results", "aggregatedTestResults", False),
]
- helpers.convert_mapping_to_xml(
- phaseJob, project, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(phaseJob, project, mapping, fail_required=True)
# Retry job
- retry = project.get('retry', False)
+ retry = project.get("retry", False)
if retry:
- max_retry = retry.get('max-retry', 0)
+ max_retry = retry.get("max-retry", 0)
mapping = [
- ('strategy-path', 'parsingRulesPath', None),
- ('', 'maxRetries', int(max_retry)),
- ('', 'enableRetryStrategy', True),
+ ("strategy-path", "parsingRulesPath", None),
+ ("", "maxRetries", int(max_retry)),
+ ("", "enableRetryStrategy", True),
]
- helpers.convert_mapping_to_xml(phaseJob,
- retry, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(phaseJob, retry, mapping, fail_required=True)
else:
- XML.SubElement(phaseJob, 'enableRetryStrategy').text = 'false'
+ XML.SubElement(phaseJob, "enableRetryStrategy").text = "false"
# Restrict matrix jobs to a subset
- if project.get('restrict-matrix-project') is not None:
+ if project.get("restrict-matrix-project") is not None:
subset = XML.SubElement(
- configs, 'hudson.plugins.parameterizedtrigger.'
- 'matrix.MatrixSubsetBuildParameters')
- mapping = [
- ('restrict-matrix-project', 'filter', None),
- ]
- helpers.convert_mapping_to_xml(subset,
- project, mapping, fail_required=True)
+ configs,
+ "hudson.plugins.parameterizedtrigger."
+ "matrix.MatrixSubsetBuildParameters",
+ )
+ mapping = [("restrict-matrix-project", "filter", None)]
+ helpers.convert_mapping_to_xml(subset, project, mapping, fail_required=True)
# Enable Condition
- enable_condition = project.get('enable-condition')
+ enable_condition = project.get("enable-condition")
if enable_condition is not None:
mapping = [
- ('', 'enableCondition', True),
- ('', 'condition', enable_condition),
+ ("", "enableCondition", True),
+ ("", "condition", enable_condition),
]
- helpers.convert_mapping_to_xml(phaseJob,
- project, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(
+ phaseJob, project, mapping, fail_required=True
+ )
# Kill phase on job status
- kill_status = project.get('kill-phase-on')
+ kill_status = project.get("kill-phase-on")
if kill_status is not None:
kill_status = kill_status.upper()
mapping = [
- ('', 'killPhaseOnJobResultCondition',
- kill_status, kill_status_list),
+ ("", "killPhaseOnJobResultCondition", kill_status, kill_status_list)
]
- helpers.convert_mapping_to_xml(phaseJob,
- project, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(
+ phaseJob, project, mapping, fail_required=True
+ )
def config_file_provider(registry, xml_parent, data):
@@ -2167,10 +2159,10 @@ def config_file_provider(registry, xml_parent, data):
../../tests/builders/fixtures/config-file-provider-minimal.yaml
:language: yaml
"""
- cfp = XML.SubElement(xml_parent,
- 'org.jenkinsci.plugins.configfiles.builder.'
- 'ConfigFileBuildStep')
- cfp.set('plugin', 'config-file-provider')
+ cfp = XML.SubElement(
+ xml_parent, "org.jenkinsci.plugins.configfiles.builder." "ConfigFileBuildStep"
+ )
+ cfp.set("plugin", "config-file-provider")
helpers.config_file_provider_builder(cfp, data)
@@ -2214,25 +2206,24 @@ def grails(registry, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/grails-minimal.yaml
:language: yaml
"""
- grails = XML.SubElement(xml_parent, 'com.g2one.hudson.grails.'
- 'GrailsBuilder')
- grails.set('plugin', 'grails')
+ grails = XML.SubElement(xml_parent, "com.g2one.hudson.grails." "GrailsBuilder")
+ grails.set("plugin", "grails")
mappings = [
- ('targets', 'targets', None),
- ('name', 'name', '(Default)'),
- ('work-dir', 'grailsWorkDir', ''),
- ('project-dir', 'projectWorkDir', ''),
- ('base-dir', 'projectBaseDir', ''),
- ('server-port', 'serverPort', ''),
- ('properties', 'properties', ''),
- ('force-upgrade', 'forceUpgrade', False),
- ('non-interactive', 'nonInteractive', False),
- ('use-wrapper', 'useWrapper', False),
- ('plain-output', 'plainOutput', False),
- ('stack-trace', 'stackTrace', False),
- ('verbose', 'verbose', False),
- ('refresh-dependencies', 'refreshDependencies', False),
+ ("targets", "targets", None),
+ ("name", "name", "(Default)"),
+ ("work-dir", "grailsWorkDir", ""),
+ ("project-dir", "projectWorkDir", ""),
+ ("base-dir", "projectBaseDir", ""),
+ ("server-port", "serverPort", ""),
+ ("properties", "properties", ""),
+ ("force-upgrade", "forceUpgrade", False),
+ ("non-interactive", "nonInteractive", False),
+ ("use-wrapper", "useWrapper", False),
+ ("plain-output", "plainOutput", False),
+ ("stack-trace", "stackTrace", False),
+ ("verbose", "verbose", False),
+ ("refresh-dependencies", "refreshDependencies", False),
]
helpers.convert_mapping_to_xml(grails, data, mappings, fail_required=True)
@@ -2257,14 +2248,13 @@ def sbt(registry, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/sbt.yaml
:language: yaml
"""
- sbt = XML.SubElement(xml_parent, 'org.jvnet.hudson.plugins.'
- 'SbtPluginBuilder')
+ sbt = XML.SubElement(xml_parent, "org.jvnet.hudson.plugins." "SbtPluginBuilder")
mappings = [
- ('name', 'name', ''),
- ('jvm-flags', 'jvmFlags', ''),
- ('sbt-flags', 'sbtFlags', '-Dsbt.log.noformat=true'),
- ('actions', 'actions', ''),
- ('subdir-path', 'subdirPath', ''),
+ ("name", "name", ""),
+ ("jvm-flags", "jvmFlags", ""),
+ ("sbt-flags", "sbtFlags", "-Dsbt.log.noformat=true"),
+ ("actions", "actions", ""),
+ ("subdir-path", "subdirPath", ""),
]
helpers.convert_mapping_to_xml(sbt, data, mappings, fail_required=True)
@@ -2286,8 +2276,9 @@ def critical_block_start(registry, xml_parent, data):
:language: yaml
"""
cbs = XML.SubElement(
- xml_parent, 'org.jvnet.hudson.plugins.exclusion.CriticalBlockStart')
- cbs.set('plugin', 'Exclusion')
+ xml_parent, "org.jvnet.hudson.plugins.exclusion.CriticalBlockStart"
+ )
+ cbs.set("plugin", "Exclusion")
def critical_block_end(registry, xml_parent, data):
@@ -2307,8 +2298,9 @@ def critical_block_end(registry, xml_parent, data):
:language: yaml
"""
cbs = XML.SubElement(
- xml_parent, 'org.jvnet.hudson.plugins.exclusion.CriticalBlockEnd')
- cbs.set('plugin', 'Exclusion')
+ xml_parent, "org.jvnet.hudson.plugins.exclusion.CriticalBlockEnd"
+ )
+ cbs.set("plugin", "Exclusion")
def publish_over_ssh(registry, xml_parent, data):
@@ -2407,139 +2399,139 @@ def saltstack(parser, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/saltstack-full.yaml
:language: yaml
"""
- saltstack = XML.SubElement(xml_parent, 'com.waytta.SaltAPIBuilder')
-
- supported_auth_types = ['pam', 'ldap']
- supported_target_types = ['glob', 'pcre', 'list', 'grain', 'pillar',
- 'nodegroup', 'range', 'compound']
- supported_client_interfaces = ['local', 'local-batch', 'runner']
+ saltstack = XML.SubElement(xml_parent, "com.waytta.SaltAPIBuilder")
+
+ supported_auth_types = ["pam", "ldap"]
+ supported_target_types = [
+ "glob",
+ "pcre",
+ "list",
+ "grain",
+ "pillar",
+ "nodegroup",
+ "range",
+ "compound",
+ ]
+ supported_client_interfaces = ["local", "local-batch", "runner"]
mapping = [
- ('servername', 'servername', None),
- ('credentials', 'credentialsId', None),
- ('authtype', 'authtype', 'pam', supported_auth_types),
- ('target', 'target', ''),
- ('targettype', 'targettype', 'glob', supported_target_types),
- ('clientinterface', 'clientInterface', 'local',
- supported_client_interfaces),
- ('function', 'function', ''),
- ('arguments', 'arguments', ''),
- ('kwarguments', 'kwarguments', ''),
- ('setpillardata', 'usePillar', False),
- ('pillarkey', 'pillarkey', ''),
- ('pillarvalue', 'pillarvalue', ''),
- ('wait', 'blockbuild', False),
- ('polltime', 'jobPollTime', ''),
- ('batchsize', 'batchSize', '100%'),
- ('mods', 'mods', ''),
- ('saveoutput', 'saveEnvVar', False),
+ ("servername", "servername", None),
+ ("credentials", "credentialsId", None),
+ ("authtype", "authtype", "pam", supported_auth_types),
+ ("target", "target", ""),
+ ("targettype", "targettype", "glob", supported_target_types),
+ ("clientinterface", "clientInterface", "local", supported_client_interfaces),
+ ("function", "function", ""),
+ ("arguments", "arguments", ""),
+ ("kwarguments", "kwarguments", ""),
+ ("setpillardata", "usePillar", False),
+ ("pillarkey", "pillarkey", ""),
+ ("pillarvalue", "pillarvalue", ""),
+ ("wait", "blockbuild", False),
+ ("polltime", "jobPollTime", ""),
+ ("batchsize", "batchSize", "100%"),
+ ("mods", "mods", ""),
+ ("saveoutput", "saveEnvVar", False),
]
- helpers.convert_mapping_to_xml(saltstack, data, mapping,
- fail_required=True)
+ helpers.convert_mapping_to_xml(saltstack, data, mapping, fail_required=True)
- clientInterface = data.get('clientinterface', 'local')
- blockbuild = str(data.get('wait', False)).lower()
- jobPollTime = str(data.get('polltime', ''))
- batchSize = data.get('batchsize', '100%')
- mods = data.get('mods', '')
- usePillar = str(data.get('setpillardata', False)).lower()
+ clientInterface = data.get("clientinterface", "local")
+ blockbuild = str(data.get("wait", False)).lower()
+ jobPollTime = str(data.get("polltime", ""))
+ batchSize = data.get("batchsize", "100%")
+ mods = data.get("mods", "")
+ usePillar = str(data.get("setpillardata", False)).lower()
# Build the clientInterfaces structure, based on the
# clientinterface setting
- clientInterfaces = XML.SubElement(saltstack, 'clientInterfaces')
- XML.SubElement(clientInterfaces, 'nullObject').text = 'false'
+ clientInterfaces = XML.SubElement(saltstack, "clientInterfaces")
+ XML.SubElement(clientInterfaces, "nullObject").text = "false"
ci_attrib = {
- 'class': 'org.apache.commons.collections.map.ListOrderedMap',
- 'serialization': 'custom'
+ "class": "org.apache.commons.collections.map.ListOrderedMap",
+ "serialization": "custom",
}
- properties = XML.SubElement(clientInterfaces, 'properties', ci_attrib)
+ properties = XML.SubElement(clientInterfaces, "properties", ci_attrib)
- lomElement = 'org.apache.commons.collections.map.ListOrderedMap'
+ lomElement = "org.apache.commons.collections.map.ListOrderedMap"
listOrderedMap = XML.SubElement(properties, lomElement)
- default = XML.SubElement(listOrderedMap, 'default')
- ordered_map = XML.SubElement(listOrderedMap, 'map')
+ default = XML.SubElement(listOrderedMap, "default")
+ ordered_map = XML.SubElement(listOrderedMap, "map")
- insertOrder = XML.SubElement(default, 'insertOrder')
+ insertOrder = XML.SubElement(default, "insertOrder")
ci_config = []
- if clientInterface == 'local':
+ if clientInterface == "local":
ci_config = [
- ('blockbuild', blockbuild),
- ('jobPollTime', jobPollTime),
- ('clientInterface', clientInterface)
+ ("blockbuild", blockbuild),
+ ("jobPollTime", jobPollTime),
+ ("clientInterface", clientInterface),
]
- elif clientInterface == 'local-batch':
- ci_config = [
- ('batchSize', batchSize),
- ('clientInterface', clientInterface)
- ]
+ elif clientInterface == "local-batch":
+ ci_config = [("batchSize", batchSize), ("clientInterface", clientInterface)]
- elif clientInterface == 'runner':
- ci_config = [
- ('mods', mods),
- ('clientInterface', clientInterface)
- ]
+ elif clientInterface == "runner":
+ ci_config = [("mods", mods), ("clientInterface", clientInterface)]
- if usePillar == 'true':
- ci_config.append(('usePillar', usePillar))
+ if usePillar == "true":
+ ci_config.append(("usePillar", usePillar))
pillar_cfg = [
- ('pillarkey', data.get('pillarkey')),
- ('pillarvalue', data.get('pillarvalue'))
+ ("pillarkey", data.get("pillarkey")),
+ ("pillarvalue", data.get("pillarvalue")),
]
for emt, value in ci_config:
- XML.SubElement(insertOrder, 'string').text = emt
- entry = XML.SubElement(ordered_map, 'entry')
- XML.SubElement(entry, 'string').text = emt
+ XML.SubElement(insertOrder, "string").text = emt
+ entry = XML.SubElement(ordered_map, "entry")
+ XML.SubElement(entry, "string").text = emt
# Special handling when usePillar == true, requires additional
# structure in the builder XML
- if emt != 'usePillar':
- XML.SubElement(entry, 'string').text = value
+ if emt != "usePillar":
+ XML.SubElement(entry, "string").text = value
else:
- jsonobj = XML.SubElement(entry, 'net.sf.json.JSONObject')
- XML.SubElement(jsonobj, 'nullObject').text = 'false'
+ jsonobj = XML.SubElement(entry, "net.sf.json.JSONObject")
+ XML.SubElement(jsonobj, "nullObject").text = "false"
- pillarProps = XML.SubElement(jsonobj, 'properties', ci_attrib)
- XML.SubElement(pillarProps, 'unserializable-parents')
+ pillarProps = XML.SubElement(jsonobj, "properties", ci_attrib)
+ XML.SubElement(pillarProps, "unserializable-parents")
pillarLom = XML.SubElement(pillarProps, lomElement)
- pillarDefault = XML.SubElement(pillarLom, 'default')
- pillarMap = XML.SubElement(pillarLom, 'map')
- pillarInsertOrder = XML.SubElement(pillarDefault, 'insertOrder')
+ pillarDefault = XML.SubElement(pillarLom, "default")
+ pillarMap = XML.SubElement(pillarLom, "map")
+ pillarInsertOrder = XML.SubElement(pillarDefault, "insertOrder")
for pemt, value in pillar_cfg:
- XML.SubElement(pillarInsertOrder, 'string').text = pemt
- pillarEntry = XML.SubElement(pillarMap, 'entry')
- XML.SubElement(pillarEntry, 'string').text = pemt
- XML.SubElement(pillarEntry, 'string').text = value
+ XML.SubElement(pillarInsertOrder, "string").text = pemt
+ pillarEntry = XML.SubElement(pillarMap, "entry")
+ XML.SubElement(pillarEntry, "string").text = pemt
+ XML.SubElement(pillarEntry, "string").text = value
class Builders(jenkins_jobs.modules.base.Base):
sequence = 60
- component_type = 'builder'
- component_list_type = 'builders'
+ component_type = "builder"
+ component_list_type = "builders"
def gen_xml(self, xml_parent, data):
- for alias in ['prebuilders', 'builders', 'postbuilders']:
+ for alias in ["prebuilders", "builders", "postbuilders"]:
if alias in data:
builders = XML.SubElement(xml_parent, alias)
for builder in data[alias]:
- self.registry.dispatch('builder', builders, builder)
+ self.registry.dispatch("builder", builders, builder)
# Make sure freestyle projects always have a <builders> entry
# or Jenkins v1.472 (at least) will NPE.
- project_type = data.get('project-type', 'freestyle')
- if project_type in ('freestyle', 'matrix') and 'builders' not in data:
- XML.SubElement(xml_parent, 'builders')
+ project_type = data.get("project-type", "freestyle")
+ if project_type in ("freestyle", "matrix") and "builders" not in data:
+ XML.SubElement(xml_parent, "builders")
def shining_panda(registry, xml_parent, data):
@@ -2609,52 +2601,46 @@ def shining_panda(registry, xml_parent, data):
:language: yaml
"""
- pluginelementpart = 'jenkins.plugins.shiningpanda.builders.'
- buildenvdict = {'custom': 'CustomPythonBuilder',
- 'virtualenv': 'VirtualenvBuilder',
- 'python': 'PythonBuilder'}
- envs = (buildenvdict.keys())
+ pluginelementpart = "jenkins.plugins.shiningpanda.builders."
+ buildenvdict = {
+ "custom": "CustomPythonBuilder",
+ "virtualenv": "VirtualenvBuilder",
+ "python": "PythonBuilder",
+ }
+ envs = buildenvdict.keys()
try:
- buildenv = data['build-environment']
+ buildenv = data["build-environment"]
except KeyError:
- raise MissingAttributeError('build-environment')
+ raise MissingAttributeError("build-environment")
if buildenv not in envs:
- raise InvalidAttributeError('build-environment', buildenv, envs)
+ raise InvalidAttributeError("build-environment", buildenv, envs)
- t = XML.SubElement(xml_parent, '%s%s' %
- (pluginelementpart, buildenvdict[buildenv]))
+ t = XML.SubElement(xml_parent, "%s%s" % (pluginelementpart, buildenvdict[buildenv]))
- if buildenv in ('python', 'virtualenv'):
- python_mapping = [
- ('python-version', 'pythonName', 'System-CPython-2.7'),
- ]
- helpers.convert_mapping_to_xml(
- t, data, python_mapping, fail_required=True)
+ if buildenv in ("python", "virtualenv"):
+ python_mapping = [("python-version", "pythonName", "System-CPython-2.7")]
+ helpers.convert_mapping_to_xml(t, data, python_mapping, fail_required=True)
- if buildenv in 'custom':
- custom_mapping = [
- ('home', 'home', None),
- ]
- helpers.convert_mapping_to_xml(
- t, data, custom_mapping, fail_required=True)
- if buildenv in 'virtualenv':
+ if buildenv in "custom":
+ custom_mapping = [("home", "home", None)]
+ helpers.convert_mapping_to_xml(t, data, custom_mapping, fail_required=True)
+ if buildenv in "virtualenv":
virtualenv_mapping = [
- ('name', 'home', ''),
- ('clear', 'clear', False),
- ('use-distribute', 'useDistribute', False),
- ('system-site-packages', 'systemSitePackages', False),
+ ("name", "home", ""),
+ ("clear", "clear", False),
+ ("use-distribute", "useDistribute", False),
+ ("system-site-packages", "systemSitePackages", False),
]
- helpers.convert_mapping_to_xml(
- t, data, virtualenv_mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(t, data, virtualenv_mapping, fail_required=True)
# Common arguments
- naturelist = ['shell', 'xshell', 'python']
+ naturelist = ["shell", "xshell", "python"]
mapping = [
- ('nature', 'nature', 'shell', naturelist),
- ('command', 'command', ""),
- ('ignore-exit-code', 'ignoreExitCode', False),
+ ("nature", "nature", "shell", naturelist),
+ ("command", "command", ""),
+ ("ignore-exit-code", "ignoreExitCode", False),
]
helpers.convert_mapping_to_xml(t, data, mapping, fail_required=True)
@@ -2675,16 +2661,13 @@ def tox(registry, xml_parent, data):
.. literalinclude:: /../../tests/builders/fixtures/tox001.yaml
:language: yaml
"""
- pluginelement = 'jenkins.plugins.shiningpanda.builders.ToxBuilder'
+ pluginelement = "jenkins.plugins.shiningpanda.builders.ToxBuilder"
t = XML.SubElement(xml_parent, pluginelement)
- mappings = [
- ('ini', 'toxIni', 'tox.ini'),
- ('recreate', 'recreate', False),
- ]
+ mappings = [("ini", "toxIni", "tox.ini"), ("recreate", "recreate", False)]
helpers.convert_mapping_to_xml(t, data, mappings, fail_required=True)
- pattern = data.get('toxenv-pattern')
+ pattern = data.get("toxenv-pattern")
if pattern:
- XML.SubElement(t, 'toxenvPattern').text = pattern
+ XML.SubElement(t, "toxenvPattern").text = pattern
def managed_script(registry, xml_parent, data):
@@ -2710,24 +2693,21 @@ def managed_script(registry, xml_parent, data):
.. literalinclude:: /../../tests/builders/fixtures/managed-winbatch.yaml
:language: yaml
"""
- step_type = data.get('type', 'script').lower()
- if step_type == 'script':
- step = 'ScriptBuildStep'
- script_tag = 'buildStepId'
- elif step_type == 'batch':
- step = 'WinBatchBuildStep'
- script_tag = 'command'
+ step_type = data.get("type", "script").lower()
+ if step_type == "script":
+ step = "ScriptBuildStep"
+ script_tag = "buildStepId"
+ elif step_type == "batch":
+ step = "WinBatchBuildStep"
+ script_tag = "command"
else:
- raise InvalidAttributeError('type', step_type, ['script', 'batch'])
- ms = XML.SubElement(xml_parent,
- 'org.jenkinsci.plugins.managedscripts.' + step)
- mapping = [
- ('script-id', script_tag, None),
- ]
+ raise InvalidAttributeError("type", step_type, ["script", "batch"])
+ ms = XML.SubElement(xml_parent, "org.jenkinsci.plugins.managedscripts." + step)
+ mapping = [("script-id", script_tag, None)]
helpers.convert_mapping_to_xml(ms, data, mapping, fail_required=True)
- args = XML.SubElement(ms, 'buildStepArgs')
- for arg in data.get('args', []):
- XML.SubElement(args, 'string').text = arg
+ args = XML.SubElement(ms, "buildStepArgs")
+ for arg in data.get("args", []):
+ XML.SubElement(args, "string").text = arg
def cmake(registry, xml_parent, data):
@@ -2836,59 +2816,55 @@ def cmake(registry, xml_parent, data):
:language: yaml
"""
- BUILD_TYPES = ['Debug', 'Release', 'RelWithDebInfo', 'MinSizeRel']
- cmake = XML.SubElement(xml_parent, 'hudson.plugins.cmake.CmakeBuilder')
+ BUILD_TYPES = ["Debug", "Release", "RelWithDebInfo", "MinSizeRel"]
+ cmake = XML.SubElement(xml_parent, "hudson.plugins.cmake.CmakeBuilder")
mapping = [
- ('source-dir', 'sourceDir', None), # Required parameter
- ('generator', 'generator', "Unix Makefiles"),
- ('clean-build-dir', 'cleanBuild', False),
+ ("source-dir", "sourceDir", None), # Required parameter
+ ("generator", "generator", "Unix Makefiles"),
+ ("clean-build-dir", "cleanBuild", False),
]
- helpers.convert_mapping_to_xml(
- cmake, data, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(cmake, data, mapping, fail_required=True)
info = registry.get_plugin_info("CMake plugin")
# Note: Assume latest version of plugin is preferred config format
- version = pkg_resources.parse_version(
- info.get("version", str(sys.maxsize)))
+ version = pkg_resources.parse_version(info.get("version", str(sys.maxsize)))
if version >= pkg_resources.parse_version("2.0"):
mapping_20 = [
- ('preload-script', 'preloadScript', None), # Optional parameter
- ('working-dir', 'workingDir', ''),
- ('build-type', 'buildType', 'Debug'),
- ('installation-name', 'installationName', 'InSearchPath'),
- ('other-arguments', 'toolArgs', ''),
+ ("preload-script", "preloadScript", None), # Optional parameter
+ ("working-dir", "workingDir", ""),
+ ("build-type", "buildType", "Debug"),
+ ("installation-name", "installationName", "InSearchPath"),
+ ("other-arguments", "toolArgs", ""),
]
- helpers.convert_mapping_to_xml(
- cmake, data, mapping_20, fail_required=False)
+ helpers.convert_mapping_to_xml(cmake, data, mapping_20, fail_required=False)
- tool_steps = XML.SubElement(cmake, 'toolSteps')
+ tool_steps = XML.SubElement(cmake, "toolSteps")
- for step_data in data.get('build-tool-invocations', []):
- step = XML.SubElement(
- tool_steps, 'hudson.plugins.cmake.BuildToolStep')
+ for step_data in data.get("build-tool-invocations", []):
+ step = XML.SubElement(tool_steps, "hudson.plugins.cmake.BuildToolStep")
step_mapping = [
- ('use-cmake', 'withCmake', False),
- ('arguments', 'args', ''),
- ('environment-variables', 'vars', ''),
+ ("use-cmake", "withCmake", False),
+ ("arguments", "args", ""),
+ ("environment-variables", "vars", ""),
]
helpers.convert_mapping_to_xml(
- step, step_data, step_mapping, fail_required=True)
+ step, step_data, step_mapping, fail_required=True
+ )
else:
mapping_10 = [
- ('preload-script', 'preloadScript', ''),
- ('build-dir', 'buildDir', ''),
- ('install-dir', 'installDir', ''),
- ('make-command', 'makeCommand', 'make'),
- ('install-command', 'installCommand', 'make install'),
- ('other-arguments', 'cmakeArgs', ''),
- ('custom-cmake-path', 'projectCmakePath', ''),
- ('clean-install-dir', 'cleanInstallDir', False),
+ ("preload-script", "preloadScript", ""),
+ ("build-dir", "buildDir", ""),
+ ("install-dir", "installDir", ""),
+ ("make-command", "makeCommand", "make"),
+ ("install-command", "installCommand", "make install"),
+ ("other-arguments", "cmakeArgs", ""),
+ ("custom-cmake-path", "projectCmakePath", ""),
+ ("clean-install-dir", "cleanInstallDir", False),
]
- helpers.convert_mapping_to_xml(
- cmake, data, mapping_10, fail_required=True)
+ helpers.convert_mapping_to_xml(cmake, data, mapping_10, fail_required=True)
# The options buildType and otherBuildType work together on the CMake
# plugin:
@@ -2900,20 +2876,20 @@ def cmake(registry, xml_parent, data):
# It is strange and confusing that the plugin author chose to do
# something like that instead of simply passing a string "buildType"
# option, so this was done to simplify it for the JJB user.
- build_type = XML.SubElement(cmake, 'buildType')
- build_type.text = data.get('build-type', BUILD_TYPES[0])
- other_build_type = XML.SubElement(cmake, 'otherBuildType')
+ build_type = XML.SubElement(cmake, "buildType")
+ build_type.text = data.get("build-type", BUILD_TYPES[0])
+ other_build_type = XML.SubElement(cmake, "otherBuildType")
if build_type.text not in BUILD_TYPES:
other_build_type.text = build_type.text
build_type.text = BUILD_TYPES[0]
else:
- other_build_type.text = ''
+ other_build_type.text = ""
# The plugin generates this tag, but there doesn't seem to be anything
# that can be configurable by it. Let's keep it to maintain
# compatibility:
- XML.SubElement(cmake, 'builderImpl')
+ XML.SubElement(cmake, "builderImpl")
def dsl(registry, xml_parent, data):
@@ -2950,61 +2926,61 @@ def dsl(registry, xml_parent, data):
"""
- dsl = XML.SubElement(xml_parent,
- 'javaposse.jobdsl.plugin.ExecuteDslScripts')
+ dsl = XML.SubElement(xml_parent, "javaposse.jobdsl.plugin.ExecuteDslScripts")
- if 'target' in data:
- if 'targets' not in data:
- logger.warning("Converting from old format of 'target' to new "
- "name 'targets', please update your job "
- "definitions.")
- data['targets'] = data['target']
+ if "target" in data:
+ if "targets" not in data:
+ logger.warning(
+ "Converting from old format of 'target' to new "
+ "name 'targets', please update your job "
+ "definitions."
+ )
+ data["targets"] = data["target"]
else:
- logger.warning("Ignoring old argument 'target' in favour of new "
- "format argument 'targets', please remove old "
- "format.")
-
- if data.get('script-text'):
- XML.SubElement(dsl, 'scriptText').text = data.get('script-text')
- XML.SubElement(dsl, 'usingScriptText').text = 'true'
- elif data.get('targets'):
- XML.SubElement(dsl, 'targets').text = data.get('targets')
- XML.SubElement(dsl, 'usingScriptText').text = 'false'
+ logger.warning(
+ "Ignoring old argument 'target' in favour of new "
+ "format argument 'targets', please remove old "
+ "format."
+ )
+
+ if data.get("script-text"):
+ XML.SubElement(dsl, "scriptText").text = data.get("script-text")
+ XML.SubElement(dsl, "usingScriptText").text = "true"
+ elif data.get("targets"):
+ XML.SubElement(dsl, "targets").text = data.get("targets")
+ XML.SubElement(dsl, "usingScriptText").text = "false"
else:
- raise MissingAttributeError(['script-text', 'target'])
+ raise MissingAttributeError(["script-text", "target"])
- XML.SubElement(dsl, 'ignoreExisting').text = str(data.get(
- 'ignore-existing', False)).lower()
+ XML.SubElement(dsl, "ignoreExisting").text = str(
+ data.get("ignore-existing", False)
+ ).lower()
- supportedJobActions = ['IGNORE', 'DISABLE', 'DELETE']
- removedJobAction = data.get('removed-job-action',
- supportedJobActions[0])
+ supportedJobActions = ["IGNORE", "DISABLE", "DELETE"]
+ removedJobAction = data.get("removed-job-action", supportedJobActions[0])
if removedJobAction not in supportedJobActions:
- raise InvalidAttributeError('removed-job-action',
- removedJobAction,
- supportedJobActions)
- XML.SubElement(dsl, 'removedJobAction').text = removedJobAction
-
- supportedViewActions = ['IGNORE', 'DELETE']
- removedViewAction = data.get('removed-view-action',
- supportedViewActions[0])
+ raise InvalidAttributeError(
+ "removed-job-action", removedJobAction, supportedJobActions
+ )
+ XML.SubElement(dsl, "removedJobAction").text = removedJobAction
+
+ supportedViewActions = ["IGNORE", "DELETE"]
+ removedViewAction = data.get("removed-view-action", supportedViewActions[0])
if removedViewAction not in supportedViewActions:
- raise InvalidAttributeError('removed-view-action',
- removedViewAction,
- supportedViewActions)
- XML.SubElement(dsl, 'removedViewAction').text = removedViewAction
-
- supportedLookupActions = ['JENKINS_ROOT', 'SEED_JOB']
- lookupStrategy = data.get('lookup-strategy',
- supportedLookupActions[0])
+ raise InvalidAttributeError(
+ "removed-view-action", removedViewAction, supportedViewActions
+ )
+ XML.SubElement(dsl, "removedViewAction").text = removedViewAction
+
+ supportedLookupActions = ["JENKINS_ROOT", "SEED_JOB"]
+ lookupStrategy = data.get("lookup-strategy", supportedLookupActions[0])
if lookupStrategy not in supportedLookupActions:
- raise InvalidAttributeError('lookup-strategy',
- lookupStrategy,
- supportedLookupActions)
- XML.SubElement(dsl, 'lookupStrategy').text = lookupStrategy
+ raise InvalidAttributeError(
+ "lookup-strategy", lookupStrategy, supportedLookupActions
+ )
+ XML.SubElement(dsl, "lookupStrategy").text = lookupStrategy
- XML.SubElement(dsl, 'additionalClasspath').text = data.get(
- 'additional-classpath')
+ XML.SubElement(dsl, "additionalClasspath").text = data.get("additional-classpath")
def github_notifier(registry, xml_parent, data):
@@ -3017,8 +2993,7 @@ def github_notifier(registry, xml_parent, data):
.. literalinclude:: /../../tests/builders/fixtures/github-notifier.yaml
:language: yaml
"""
- XML.SubElement(xml_parent,
- 'com.cloudbees.jenkins.GitHubSetCommitStatusBuilder')
+ XML.SubElement(xml_parent, "com.cloudbees.jenkins.GitHubSetCommitStatusBuilder")
def scan_build(registry, xml_parent, data):
@@ -3063,23 +3038,21 @@ def scan_build(registry, xml_parent, data):
:language: yaml
"""
p = XML.SubElement(
- xml_parent,
- 'jenkins.plugins.clangscanbuild.ClangScanBuildBuilder')
- p.set('plugin', 'clang-scanbuild')
+ xml_parent, "jenkins.plugins.clangscanbuild.ClangScanBuildBuilder"
+ )
+ p.set("plugin", "clang-scanbuild")
mappings = [
- ('target', 'target', None),
- ('target-sdk', 'targetSdk', 'iphonesimulator'),
- ('config', 'config', 'Debug'),
- ('clang-install-name', 'clangInstallationName', ''),
- ('xcode-sub-path', 'xcodeProjectSubPath', 'myProj/subfolder'),
- ('workspace', 'workspace', ''),
- ('scheme', 'scheme', ''),
- ('scan-build-args', 'scanbuildargs', '--use-analyzer Xcode'),
- ('xcode-build-args',
- 'xcodebuildargs',
- '-derivedDataPath $WORKSPACE/build'),
- ('report-folder', 'outputFolderName', 'clangScanBuildReports'),
+ ("target", "target", None),
+ ("target-sdk", "targetSdk", "iphonesimulator"),
+ ("config", "config", "Debug"),
+ ("clang-install-name", "clangInstallationName", ""),
+ ("xcode-sub-path", "xcodeProjectSubPath", "myProj/subfolder"),
+ ("workspace", "workspace", ""),
+ ("scheme", "scheme", ""),
+ ("scan-build-args", "scanbuildargs", "--use-analyzer Xcode"),
+ ("xcode-build-args", "xcodebuildargs", "-derivedDataPath $WORKSPACE/build"),
+ ("report-folder", "outputFolderName", "clangScanBuildReports"),
]
helpers.convert_mapping_to_xml(p, data, mappings, fail_required=True)
@@ -3098,13 +3071,9 @@ def ssh_builder(registry, xml_parent, data):
.. literalinclude:: /../../tests/builders/fixtures/ssh-builder.yaml
:language: yaml
"""
- builder = XML.SubElement(
- xml_parent, 'org.jvnet.hudson.plugins.SSHBuilder')
+ builder = XML.SubElement(xml_parent, "org.jvnet.hudson.plugins.SSHBuilder")
- mapping = [
- ('ssh-user-ip', 'siteName', None),
- ('command', 'command', None),
- ]
+ mapping = [("ssh-user-ip", "siteName", None), ("command", "command", None)]
helpers.convert_mapping_to_xml(builder, data, mapping, fail_required=True)
@@ -3132,21 +3101,20 @@ def sonar(registry, xml_parent, data):
.. literalinclude:: /../../tests/builders/fixtures/sonar.yaml
:language: yaml
"""
- sonar = XML.SubElement(xml_parent,
- 'hudson.plugins.sonar.SonarRunnerBuilder')
- sonar.set('plugin', 'sonar')
- XML.SubElement(sonar, 'installationName').text = data['sonar-name']
+ sonar = XML.SubElement(xml_parent, "hudson.plugins.sonar.SonarRunnerBuilder")
+ sonar.set("plugin", "sonar")
+ XML.SubElement(sonar, "installationName").text = data["sonar-name"]
mappings = [
- ('scanner-name', 'sonarScannerName', ''),
- ('task', 'task', ''),
- ('project', 'project', ''),
- ('properties', 'properties', ''),
- ('java-opts', 'javaOpts', ''),
- ('additional-arguments', 'additionalArguments', ''),
+ ("scanner-name", "sonarScannerName", ""),
+ ("task", "task", ""),
+ ("project", "project", ""),
+ ("properties", "properties", ""),
+ ("java-opts", "javaOpts", ""),
+ ("additional-arguments", "additionalArguments", ""),
]
helpers.convert_mapping_to_xml(sonar, data, mappings, fail_required=True)
- if 'jdk' in data:
- XML.SubElement(sonar, 'jdk').text = data['jdk']
+ if "jdk" in data:
+ XML.SubElement(sonar, "jdk").text = data["jdk"]
def xcode(registry, xml_parent, data):
@@ -3226,85 +3194,84 @@ def xcode(registry, xml_parent, data):
:language: yaml
"""
- if data.get('developer-profile'):
- profile = XML.SubElement(xml_parent, 'au.com.rayh.'
- 'DeveloperProfileLoader')
- mapping = [
- ('developer-profile', 'id', None),
- ]
- helpers.convert_mapping_to_xml(
- profile, data, mapping, fail_required=False)
+ if data.get("developer-profile"):
+ profile = XML.SubElement(xml_parent, "au.com.rayh." "DeveloperProfileLoader")
+ mapping = [("developer-profile", "id", None)]
+ helpers.convert_mapping_to_xml(profile, data, mapping, fail_required=False)
- xcode = XML.SubElement(xml_parent, 'au.com.rayh.XCodeBuilder')
+ xcode = XML.SubElement(xml_parent, "au.com.rayh.XCodeBuilder")
mappings = [
- ('clean-build', 'cleanBeforeBuild', False),
- ('clean-test-reports', 'cleanTestReports', False),
- ('archive', 'generateArchive', False),
- ('configuration', 'configuration', 'Release'),
- ('configuration-directory', 'configurationBuildDir', ''),
- ('target', 'target', ''),
- ('sdk', 'sdk', ''),
- ('symroot', 'symRoot', ''),
- ('project-path', 'xcodeProjectPath', ''),
- ('project-file', 'xcodeProjectFile', ''),
- ('build-arguments', 'xcodebuildArguments', ''),
- ('schema', 'xcodeSchema', ''),
- ('workspace', 'xcodeWorkspaceFile', ''),
- ('profile', 'embeddedProfileFile', ''),
- ('codesign-id', 'codeSigningIdentity', ''),
- ('allow-failing', 'allowFailingBuildResults', False),
+ ("clean-build", "cleanBeforeBuild", False),
+ ("clean-test-reports", "cleanTestReports", False),
+ ("archive", "generateArchive", False),
+ ("configuration", "configuration", "Release"),
+ ("configuration-directory", "configurationBuildDir", ""),
+ ("target", "target", ""),
+ ("sdk", "sdk", ""),
+ ("symroot", "symRoot", ""),
+ ("project-path", "xcodeProjectPath", ""),
+ ("project-file", "xcodeProjectFile", ""),
+ ("build-arguments", "xcodebuildArguments", ""),
+ ("schema", "xcodeSchema", ""),
+ ("workspace", "xcodeWorkspaceFile", ""),
+ ("profile", "embeddedProfileFile", ""),
+ ("codesign-id", "codeSigningIdentity", ""),
+ ("allow-failing", "allowFailingBuildResults", False),
]
helpers.convert_mapping_to_xml(xcode, data, mappings, fail_required=True)
- version = XML.SubElement(xcode, 'provideApplicationVersion')
- version_technical = XML.SubElement(xcode,
- 'cfBundleVersionValue')
- version_marketing = XML.SubElement(xcode,
- 'cfBundleShortVersionStringValue')
+ version = XML.SubElement(xcode, "provideApplicationVersion")
+ version_technical = XML.SubElement(xcode, "cfBundleVersionValue")
+ version_marketing = XML.SubElement(xcode, "cfBundleShortVersionStringValue")
- if data.get('version-technical') or data.get('version-marketing'):
- version.text = 'true'
- version_technical.text = data.get('version-technical', '')
- version_marketing.text = data.get('version-marketing', '')
+ if data.get("version-technical") or data.get("version-marketing"):
+ version.text = "true"
+ version_technical.text = data.get("version-technical", "")
+ version_marketing.text = data.get("version-marketing", "")
else:
- version.text = 'false'
+ version.text = "false"
- XML.SubElement(xcode, 'buildIpa').text = str(
- bool(data.get('ipa-version')) or False).lower()
+ XML.SubElement(xcode, "buildIpa").text = str(
+ bool(data.get("ipa-version")) or False
+ ).lower()
- valid_ipa_export_methods = ['', 'ad-hoc', 'app-store', 'development']
+ valid_ipa_export_methods = ["", "ad-hoc", "app-store", "development"]
mapping = [
- ('ipa-export-method', 'ipaExportMethod', '',
- valid_ipa_export_methods),
- ('ipa-version', 'ipaName', ''),
- ('ipa-output', 'ipaOutputDirectory', ''),
- ('development-team-id', 'developmentTeamID', ''),
- ('keychain-name', 'keychainName', ''),
- ('keychain-path', 'keychainPath', ''),
- ('keychain-password', 'keychainPwd', ''),
- ('keychain-unlock', 'unlockKeychain', False),
- ('compile-bitcode', 'compileBitcode', True),
- ('upload-bitcode', 'uploadBitcode', True),
- ('upload-symbols', 'uploadSymbols', True)
+ ("ipa-export-method", "ipaExportMethod", "", valid_ipa_export_methods),
+ ("ipa-version", "ipaName", ""),
+ ("ipa-output", "ipaOutputDirectory", ""),
+ ("development-team-id", "developmentTeamID", ""),
+ ("keychain-name", "keychainName", ""),
+ ("keychain-path", "keychainPath", ""),
+ ("keychain-password", "keychainPwd", ""),
+ ("keychain-unlock", "unlockKeychain", False),
+ ("compile-bitcode", "compileBitcode", True),
+ ("upload-bitcode", "uploadBitcode", True),
+ ("upload-symbols", "uploadSymbols", True),
]
helpers.convert_mapping_to_xml(xcode, data, mapping, fail_required=True)
- has_provisioning_profiles = bool(data.get('provisioning-profiles'))
- XML.SubElement(xcode, 'manualSigning').text = str(
- has_provisioning_profiles or False).lower()
+ has_provisioning_profiles = bool(data.get("provisioning-profiles"))
+ XML.SubElement(xcode, "manualSigning").text = str(
+ has_provisioning_profiles or False
+ ).lower()
if has_provisioning_profiles:
- provisioning_profiles_xml = XML.SubElement(
- xcode, 'provisioningProfiles')
+ provisioning_profiles_xml = XML.SubElement(xcode, "provisioningProfiles")
mapping = [
- ('bundle-id', 'provisioningProfileAppId', ''),
- ('provisioning-profile-uuid', 'provisioningProfileUUID', ''),
+ ("bundle-id", "provisioningProfileAppId", ""),
+ ("provisioning-profile-uuid", "provisioningProfileUUID", ""),
]
- for provisioning_profile in data.get('provisioning-profiles'):
+ for provisioning_profile in data.get("provisioning-profiles"):
provisioning_profile_xml = XML.SubElement(
- provisioning_profiles_xml, 'au.com.rayh.ProvisioningProfile')
- helpers.convert_mapping_to_xml(provisioning_profile_xml,
- provisioning_profile, mapping, fail_required=True)
+ provisioning_profiles_xml, "au.com.rayh.ProvisioningProfile"
+ )
+ helpers.convert_mapping_to_xml(
+ provisioning_profile_xml,
+ provisioning_profile,
+ mapping,
+ fail_required=True,
+ )
def sonatype_clm(registry, xml_parent, data):
@@ -3343,35 +3310,33 @@ def sonatype_clm(registry, xml_parent, data):
/../../tests/builders/fixtures/sonatype-clm-full.yaml
:language: yaml
"""
- clm = XML.SubElement(xml_parent,
- 'com.sonatype.insight.ci.hudson.PreBuildScan')
- clm.set('plugin', 'sonatype-clm-ci')
- SUPPORTED_VALUES = ['list', 'manual']
- SUPPORTED_STAGES = ['build', 'stage-release', 'release', 'operate']
-
- application_select = XML.SubElement(clm,
- 'applicationSelectType')
+ clm = XML.SubElement(xml_parent, "com.sonatype.insight.ci.hudson.PreBuildScan")
+ clm.set("plugin", "sonatype-clm-ci")
+ SUPPORTED_VALUES = ["list", "manual"]
+ SUPPORTED_STAGES = ["build", "stage-release", "release", "operate"]
+
+ application_select = XML.SubElement(clm, "applicationSelectType")
application_mappings = [
- ('value', 'value', 'list', SUPPORTED_VALUES),
- ('application-name', 'applicationId', None),
+ ("value", "value", "list", SUPPORTED_VALUES),
+ ("application-name", "applicationId", None),
]
helpers.convert_mapping_to_xml(
- application_select, data, application_mappings, fail_required=True)
+ application_select, data, application_mappings, fail_required=True
+ )
- path = XML.SubElement(clm, 'pathConfig')
+ path = XML.SubElement(clm, "pathConfig")
path_mappings = [
- ('scan-targets', 'scanTargets', ''),
- ('module-excludes', 'moduleExcludes', ''),
- ('advanced-options', 'scanProperties', ''),
+ ("scan-targets", "scanTargets", ""),
+ ("module-excludes", "moduleExcludes", ""),
+ ("advanced-options", "scanProperties", ""),
]
- helpers.convert_mapping_to_xml(
- path, data, path_mappings, fail_required=True)
+ helpers.convert_mapping_to_xml(path, data, path_mappings, fail_required=True)
mappings = [
- ('fail-on-clm-server-failure', 'failOnClmServerFailures', False),
- ('stage', 'stageId', 'build', SUPPORTED_STAGES),
- ('username', 'username', ''),
- ('password', 'password', ''),
+ ("fail-on-clm-server-failure", "failOnClmServerFailures", False),
+ ("stage", "stageId", "build", SUPPORTED_STAGES),
+ ("username", "username", ""),
+ ("password", "password", ""),
]
helpers.convert_mapping_to_xml(clm, data, mappings, fail_required=True)
@@ -3395,24 +3360,26 @@ def beaker(registry, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/beaker-content.yaml
:language: yaml
"""
- beaker = XML.SubElement(xml_parent, 'org.jenkinsci.plugins.beakerbuilder.'
- 'BeakerBuilder')
- jobSource = XML.SubElement(beaker, 'jobSource')
- if 'content' in data and 'path' in data:
+ beaker = XML.SubElement(
+ xml_parent, "org.jenkinsci.plugins.beakerbuilder." "BeakerBuilder"
+ )
+ jobSource = XML.SubElement(beaker, "jobSource")
+ if "content" in data and "path" in data:
raise JenkinsJobsException("Use just one of 'content' or 'path'")
- elif 'content' in data:
+ elif "content" in data:
jobSourceClass = "org.jenkinsci.plugins.beakerbuilder.StringJobSource"
- jobSource.set('class', jobSourceClass)
- XML.SubElement(jobSource, 'jobContent').text = data['content']
- elif 'path' in data:
+ jobSource.set("class", jobSourceClass)
+ XML.SubElement(jobSource, "jobContent").text = data["content"]
+ elif "path" in data:
jobSourceClass = "org.jenkinsci.plugins.beakerbuilder.FileJobSource"
- jobSource.set('class', jobSourceClass)
- XML.SubElement(jobSource, 'jobPath').text = data['path']
+ jobSource.set("class", jobSourceClass)
+ XML.SubElement(jobSource, "jobPath").text = data["path"]
else:
raise JenkinsJobsException("Use one of 'content' or 'path'")
- XML.SubElement(beaker, 'downloadFiles').text = str(data.get(
- 'download-logs', False)).lower()
+ XML.SubElement(beaker, "downloadFiles").text = str(
+ data.get("download-logs", False)
+ ).lower()
def cloudformation(registry, xml_parent, data):
@@ -3452,11 +3419,11 @@ def cloudformation(registry, xml_parent, data):
:language: yaml
"""
region_dict = helpers.cloudformation_region_dict()
- stacks = helpers.cloudformation_init(
- xml_parent, data, 'CloudFormationBuildStep')
+ stacks = helpers.cloudformation_init(xml_parent, data, "CloudFormationBuildStep")
for stack in data:
helpers.cloudformation_stack(
- xml_parent, stack, 'PostBuildStackBean', stacks, region_dict)
+ xml_parent, stack, "PostBuildStackBean", stacks, region_dict
+ )
def jms_messaging(registry, xml_parent, data):
@@ -3499,8 +3466,9 @@ def jms_messaging(registry, xml_parent, data):
../../tests/builders/fixtures/jms-messaging-minimal.yaml
:language: yaml
"""
- helpers.jms_messaging_common(xml_parent, 'com.redhat.jenkins.plugins.ci.'
- 'CIMessageBuilder', data)
+ helpers.jms_messaging_common(
+ xml_parent, "com.redhat.jenkins.plugins.ci." "CIMessageBuilder", data
+ )
def openshift_build_verify(registry, xml_parent, data):
@@ -3537,17 +3505,17 @@ def openshift_build_verify(registry, xml_parent, data):
../../tests/builders/fixtures/openshift-build-verify002.yaml
:language: yaml
"""
- osb = XML.SubElement(xml_parent,
- 'com.openshift.jenkins.plugins.pipeline.'
- 'OpenShiftBuildVerifier')
+ osb = XML.SubElement(
+ xml_parent, "com.openshift.jenkins.plugins.pipeline." "OpenShiftBuildVerifier"
+ )
mapping = [
# option, xml name, default value
- ("api-url", 'apiURL', 'https://openshift.default.svc.cluster.local'),
- ("bld-cfg", 'bldCfg', 'frontend'),
- ("namespace", 'namespace', 'test'),
- ("auth-token", 'authToken', ''),
- ("verbose", 'verbose', False),
+ ("api-url", "apiURL", "https://openshift.default.svc.cluster.local"),
+ ("bld-cfg", "bldCfg", "frontend"),
+ ("namespace", "namespace", "test"),
+ ("auth-token", "authToken", ""),
+ ("verbose", "verbose", False),
]
helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
@@ -3590,20 +3558,20 @@ def openshift_builder(registry, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/openshift-builder002.yaml
:language: yaml
"""
- osb = XML.SubElement(xml_parent,
- 'com.openshift.jenkins.plugins.pipeline.'
- 'OpenShiftBuilder')
+ osb = XML.SubElement(
+ xml_parent, "com.openshift.jenkins.plugins.pipeline." "OpenShiftBuilder"
+ )
mapping = [
# option, xml name, default value
- ("api-url", 'apiURL', 'https://openshift.default.svc.cluster.local'),
- ("bld-cfg", 'bldCfg', 'frontend'),
- ("namespace", 'namespace', 'test'),
- ("auth-token", 'authToken', ''),
- ("commit-ID", 'commitID', ''),
- ("verbose", 'verbose', False),
- ("build-name", 'buildName', ''),
- ("show-build-logs", 'showBuildLogs', False),
+ ("api-url", "apiURL", "https://openshift.default.svc.cluster.local"),
+ ("bld-cfg", "bldCfg", "frontend"),
+ ("namespace", "namespace", "test"),
+ ("auth-token", "authToken", ""),
+ ("commit-ID", "commitID", ""),
+ ("verbose", "verbose", False),
+ ("build-name", "buildName", ""),
+ ("show-build-logs", "showBuildLogs", False),
]
helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
@@ -3641,17 +3609,17 @@ def openshift_creator(registry, xml_parent, data):
../../tests/builders/fixtures/openshift-creator002.yaml
:language: yaml
"""
- osb = XML.SubElement(xml_parent,
- 'com.openshift.jenkins.plugins.pipeline.'
- 'OpenShiftCreator')
+ osb = XML.SubElement(
+ xml_parent, "com.openshift.jenkins.plugins.pipeline." "OpenShiftCreator"
+ )
mapping = [
# option, xml name, default value
- ("api-url", 'apiURL', 'https://openshift.default.svc.cluster.local'),
- ("jsonyaml", 'jsonyaml', ''),
- ("namespace", 'namespace', 'test'),
- ("auth-token", 'authToken', ''),
- ("verbose", 'verbose', False),
+ ("api-url", "apiURL", "https://openshift.default.svc.cluster.local"),
+ ("jsonyaml", "jsonyaml", ""),
+ ("namespace", "namespace", "test"),
+ ("auth-token", "authToken", ""),
+ ("verbose", "verbose", False),
]
helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
@@ -3691,18 +3659,19 @@ def openshift_dep_verify(registry, xml_parent, data):
../../tests/builders/fixtures/openshift-dep-verify002.yaml
:language: yaml
"""
- osb = XML.SubElement(xml_parent,
- 'com.openshift.jenkins.plugins.pipeline.'
- 'OpenShiftDeploymentVerifier')
+ osb = XML.SubElement(
+ xml_parent,
+ "com.openshift.jenkins.plugins.pipeline." "OpenShiftDeploymentVerifier",
+ )
mapping = [
# option, xml name, default value
- ("api-url", 'apiURL', 'https://openshift.default.svc.cluster.local'),
- ("dep-cfg", 'depCfg', 'frontend'),
- ("namespace", 'namespace', 'test'),
- ("replica-count", 'replicaCount', 0),
- ("auth-token", 'authToken', ''),
- ("verbose", 'verbose', False),
+ ("api-url", "apiURL", "https://openshift.default.svc.cluster.local"),
+ ("dep-cfg", "depCfg", "frontend"),
+ ("namespace", "namespace", "test"),
+ ("replica-count", "replicaCount", 0),
+ ("auth-token", "authToken", ""),
+ ("verbose", "verbose", False),
]
helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
@@ -3738,17 +3707,17 @@ def openshift_deployer(registry, xml_parent, data):
../../tests/builders/fixtures/openshift-deployer002.yaml
:language: yaml
"""
- osb = XML.SubElement(xml_parent,
- 'com.openshift.jenkins.plugins.pipeline.'
- 'OpenShiftDeployer')
+ osb = XML.SubElement(
+ xml_parent, "com.openshift.jenkins.plugins.pipeline." "OpenShiftDeployer"
+ )
mapping = [
# option, xml name, default value
- ("api-url", 'apiURL', 'https://openshift.default.svc.cluster.local'),
- ("dep-cfg", 'depCfg', 'frontend'),
- ("namespace", 'namespace', 'test'),
- ("auth-token", 'authToken', ''),
- ("verbose", 'verbose', False),
+ ("api-url", "apiURL", "https://openshift.default.svc.cluster.local"),
+ ("dep-cfg", "depCfg", "frontend"),
+ ("namespace", "namespace", "test"),
+ ("auth-token", "authToken", ""),
+ ("verbose", "verbose", False),
]
helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
@@ -3788,18 +3757,18 @@ def openshift_img_tagger(registry, xml_parent, data):
../../tests/builders/fixtures/openshift-img-tagger002.yaml
:language: yaml
"""
- osb = XML.SubElement(xml_parent,
- 'com.openshift.jenkins.plugins.pipeline.'
- 'OpenShiftImageTagger')
+ osb = XML.SubElement(
+ xml_parent, "com.openshift.jenkins.plugins.pipeline." "OpenShiftImageTagger"
+ )
mapping = [
# option, xml name, default value
- ("api-url", 'apiURL', 'https://openshift.default.svc.cluster.local'),
- ("test-tag", 'testTag', 'origin-nodejs-sample:latest'),
- ("prod-tag", 'prodTag', 'origin-nodejs-sample:prod'),
- ("namespace", 'namespace', 'test'),
- ("auth-token", 'authToken', ''),
- ("verbose", 'verbose', False),
+ ("api-url", "apiURL", "https://openshift.default.svc.cluster.local"),
+ ("test-tag", "testTag", "origin-nodejs-sample:latest"),
+ ("prod-tag", "prodTag", "origin-nodejs-sample:prod"),
+ ("namespace", "namespace", "test"),
+ ("auth-token", "authToken", ""),
+ ("verbose", "verbose", False),
]
helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
@@ -3835,18 +3804,18 @@ def openshift_scaler(registry, xml_parent, data):
.. literalinclude:: ../../tests/builders/fixtures/openshift-scaler002.yaml
:language: yaml
"""
- osb = XML.SubElement(xml_parent,
- 'com.openshift.jenkins.plugins.pipeline.'
- 'OpenShiftScaler')
+ osb = XML.SubElement(
+ xml_parent, "com.openshift.jenkins.plugins.pipeline." "OpenShiftScaler"
+ )
mapping = [
# option, xml name, default value
- ("api-url", 'apiURL', 'https://openshift.default.svc.cluster.local'),
- ("dep-cfg", 'depCfg', 'frontend'),
- ("namespace", 'namespace', 'test'),
- ("replica-count", 'replicaCount', 0),
- ("auth-token", 'authToken', ''),
- ("verbose", 'verbose', False),
+ ("api-url", "apiURL", "https://openshift.default.svc.cluster.local"),
+ ("dep-cfg", "depCfg", "frontend"),
+ ("namespace", "namespace", "test"),
+ ("replica-count", "replicaCount", 0),
+ ("auth-token", "authToken", ""),
+ ("verbose", "verbose", False),
]
helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
@@ -3881,17 +3850,17 @@ def openshift_svc_verify(registry, xml_parent, data):
../../tests/builders/fixtures/openshift-svc-verify002.yaml
:language: yaml
"""
- osb = XML.SubElement(xml_parent,
- 'com.openshift.jenkins.plugins.pipeline.'
- 'OpenShiftServiceVerifier')
+ osb = XML.SubElement(
+ xml_parent, "com.openshift.jenkins.plugins.pipeline." "OpenShiftServiceVerifier"
+ )
mapping = [
# option, xml name, default value
- ("api-url", 'apiURL', 'https://openshift.default.svc.cluster.local'),
- ("svc-name", 'svcName', 'frontend'),
- ("namespace", 'namespace', 'test'),
- ("auth-token", 'authToken', ''),
- ("verbose", 'verbose', False),
+ ("api-url", "apiURL", "https://openshift.default.svc.cluster.local"),
+ ("svc-name", "svcName", "frontend"),
+ ("namespace", "namespace", "test"),
+ ("auth-token", "authToken", ""),
+ ("verbose", "verbose", False),
]
helpers.convert_mapping_to_xml(osb, data, mapping, fail_required=True)
@@ -3915,14 +3884,15 @@ def runscope(registry, xml_parent, data):
.. literalinclude:: /../../tests/builders/fixtures/runscope-full.yaml
:language: yaml
"""
- runscope = XML.SubElement(xml_parent,
- 'com.runscope.jenkins.Runscope.RunscopeBuilder')
- runscope.set('plugin', 'runscope')
+ runscope = XML.SubElement(
+ xml_parent, "com.runscope.jenkins.Runscope.RunscopeBuilder"
+ )
+ runscope.set("plugin", "runscope")
mapping = [
- ('test-trigger-url', 'triggerEndPoint', None),
- ('access-token', 'accessToken', None),
- ('timeout', 'timeout', 60),
+ ("test-trigger-url", "triggerEndPoint", None),
+ ("access-token", "accessToken", None),
+ ("timeout", "timeout", 60),
]
helpers.convert_mapping_to_xml(runscope, data, mapping, fail_required=True)
@@ -3947,15 +3917,12 @@ def description_setter(registry, xml_parent, data):
"""
descriptionsetter = XML.SubElement(
- xml_parent,
- 'hudson.plugins.descriptionsetter.DescriptionSetterBuilder')
- mapping = [
- ('regexp', 'regexp', ''),
- ]
- if 'description' in data:
- mapping.append(('description', 'description', None))
- helpers.convert_mapping_to_xml(
- descriptionsetter, data, mapping, fail_required=True)
+ xml_parent, "hudson.plugins.descriptionsetter.DescriptionSetterBuilder"
+ )
+ mapping = [("regexp", "regexp", "")]
+ if "description" in data:
+ mapping.append(("description", "description", None))
+ helpers.convert_mapping_to_xml(descriptionsetter, data, mapping, fail_required=True)
def build_publish_docker_image(registry, xml_parent, data):
@@ -3989,33 +3956,31 @@ def build_publish_docker_image(registry, xml_parent, data):
.. literalinclude::
/../../tests/builders/fixtures/build-publish-docker-image-full.yaml
"""
- dbp = XML.SubElement(xml_parent,
- 'com.nirima.jenkins.plugins.docker.builder'
- '.DockerBuilderPublisher')
- dbp.set('plugin', 'docker-plugin')
-
- from_registry = XML.SubElement(dbp, 'fromRegistry')
- from_registry.set('plugin', 'docker-commons')
- from_registry_mapping = [
- ('docker-registry-url', 'url', ''),
- ]
+ dbp = XML.SubElement(
+ xml_parent,
+ "com.nirima.jenkins.plugins.docker.builder" ".DockerBuilderPublisher",
+ )
+ dbp.set("plugin", "docker-plugin")
+
+ from_registry = XML.SubElement(dbp, "fromRegistry")
+ from_registry.set("plugin", "docker-commons")
+ from_registry_mapping = [("docker-registry-url", "url", "")]
helpers.convert_mapping_to_xml(
- from_registry, data, from_registry_mapping,
- fail_required=False)
+ from_registry, data, from_registry_mapping, fail_required=False
+ )
- tags = XML.SubElement(dbp, 'tags')
- XML.SubElement(tags, 'string').text = data.get('image', '')
+ tags = XML.SubElement(dbp, "tags")
+ XML.SubElement(tags, "string").text = data.get("image", "")
mapping = [
- ('docker-file-directory', 'dockerFileDirectory', ''),
- ('push-on-success', 'pushOnSuccess', False),
- ('push-credentials-id', 'pushCredentialsId', ''),
- ('clean-images', 'cleanImages', False),
- ('jenkins-job-delete', 'cleanupWithJenkinsJobDelete', False),
- ('cloud', 'cloud', ''),
+ ("docker-file-directory", "dockerFileDirectory", ""),
+ ("push-on-success", "pushOnSuccess", False),
+ ("push-credentials-id", "pushCredentialsId", ""),
+ ("clean-images", "cleanImages", False),
+ ("jenkins-job-delete", "cleanupWithJenkinsJobDelete", False),
+ ("cloud", "cloud", ""),
]
- helpers.convert_mapping_to_xml(
- dbp, data, mapping, fail_required=False)
+ helpers.convert_mapping_to_xml(dbp, data, mapping, fail_required=False)
def docker_build_publish(parse, xml_parent, data):
@@ -4060,52 +4025,51 @@ def docker_build_publish(parse, xml_parent, data):
.. literalinclude:: /../../tests/builders/fixtures/docker-builder002.yaml
"""
- db = XML.SubElement(xml_parent,
- 'com.cloudbees.dockerpublish.DockerBuilder')
- db.set('plugin', 'docker-build-publish')
+ db = XML.SubElement(xml_parent, "com.cloudbees.dockerpublish.DockerBuilder")
+ db.set("plugin", "docker-build-publish")
mapping = [
- ('repo-name', 'repoName', None),
- ('repo-tag', 'repoTag', ''),
- ('no-cache', 'noCache', False),
- ('no-force-pull', 'noForcePull', False),
- ('skip-build', 'skipBuild', False),
- ('skip-decorate', 'skipDecorate', False),
- ('skip-tag-latest', 'skipTagLatest', False),
- ('skip-push', 'skipPush', False),
- ('file-path', 'dockerfilePath', ''),
- ('build-context', 'buildContext', ''),
- ('create-fingerprint', 'createFingerprint', False),
- ('build-args', 'buildAdditionalArgs', ''),
- ('force-tag', 'forceTag', False),
+ ("repo-name", "repoName", None),
+ ("repo-tag", "repoTag", ""),
+ ("no-cache", "noCache", False),
+ ("no-force-pull", "noForcePull", False),
+ ("skip-build", "skipBuild", False),
+ ("skip-decorate", "skipDecorate", False),
+ ("skip-tag-latest", "skipTagLatest", False),
+ ("skip-push", "skipPush", False),
+ ("file-path", "dockerfilePath", ""),
+ ("build-context", "buildContext", ""),
+ ("create-fingerprint", "createFingerprint", False),
+ ("build-args", "buildAdditionalArgs", ""),
+ ("force-tag", "forceTag", False),
]
helpers.convert_mapping_to_xml(db, data, mapping, fail_required=True)
mapping = []
- if 'server' in data:
- server = XML.SubElement(db, 'server')
- server.set('plugin', 'docker-commons')
- server_data = data['server']
- if 'credentials-id' in server_data:
- mapping.append(('credentials-id', 'credentialsId', None))
-
- if 'uri' in server_data:
- mapping.append(('uri', 'uri', None))
- helpers.convert_mapping_to_xml(
- server, server_data, mapping, fail_required=True)
+ if "server" in data:
+ server = XML.SubElement(db, "server")
+ server.set("plugin", "docker-commons")
+ server_data = data["server"]
+ if "credentials-id" in server_data:
+ mapping.append(("credentials-id", "credentialsId", None))
+
+ if "uri" in server_data:
+ mapping.append(("uri", "uri", None))
+ helpers.convert_mapping_to_xml(server, server_data, mapping, fail_required=True)
mappings = []
- if 'registry' in data:
- registry = XML.SubElement(db, 'registry')
- registry.set('plugin', 'docker-commons')
- registry_data = data['registry']
- if 'credentials-id' in registry_data:
- mappings.append(('credentials-id', 'credentialsId', None))
-
- if 'url' in registry_data:
- mappings.append(('url', 'url', None))
+ if "registry" in data:
+ registry = XML.SubElement(db, "registry")
+ registry.set("plugin", "docker-commons")
+ registry_data = data["registry"]
+ if "credentials-id" in registry_data:
+ mappings.append(("credentials-id", "credentialsId", None))
+
+ if "url" in registry_data:
+ mappings.append(("url", "url", None))
helpers.convert_mapping_to_xml(
- registry, registry_data, mappings, fail_required=True)
+ registry, registry_data, mappings, fail_required=True
+ )
def docker_pull_image(registry, xml_parent, data):
@@ -4131,22 +4095,23 @@ def docker_pull_image(registry, xml_parent, data):
/../../tests/builders/fixtures/docker-pull-image-full.yaml
"""
docker_pull_image = XML.SubElement(
- xml_parent, 'org.jenkinsci.plugins.registry.'
- 'notification.DockerPullImageBuilder')
- docker_pull_image.set('plugin', 'dockerhub-notification')
- registry = XML.SubElement(docker_pull_image, 'registry')
- registry.set('plugin', 'docker-commons')
- mapping = [
- ('image', 'image', ''),
- ]
+ xml_parent,
+ "org.jenkinsci.plugins.registry." "notification.DockerPullImageBuilder",
+ )
+ docker_pull_image.set("plugin", "dockerhub-notification")
+ registry = XML.SubElement(docker_pull_image, "registry")
+ registry.set("plugin", "docker-commons")
+ mapping = [("image", "image", "")]
helpers.convert_mapping_to_xml(
- docker_pull_image, data, mapping, fail_required=False)
+ docker_pull_image, data, mapping, fail_required=False
+ )
registry_mapping = [
- ('docker-registry-url', 'url', ''),
- ('credentials-id', 'credentialsId', ''),
+ ("docker-registry-url", "url", ""),
+ ("credentials-id", "credentialsId", ""),
]
helpers.convert_mapping_to_xml(
- registry, data, registry_mapping, fail_required=False)
+ registry, data, registry_mapping, fail_required=False
+ )
def build_name_setter(registry, xml_parent, data):
@@ -4177,17 +4142,16 @@ def build_name_setter(registry, xml_parent, data):
:language: yaml
"""
build_name_setter = XML.SubElement(
- xml_parent,
- 'org.jenkinsci.plugins.buildnameupdater.BuildNameUpdater')
+ xml_parent, "org.jenkinsci.plugins.buildnameupdater.BuildNameUpdater"
+ )
mapping = [
- ('name', 'buildName', 'version.txt'),
- ('template', 'macroTemplate', '#${BUILD_NUMBER}'),
- ('file', 'fromFile', False),
- ('macro', 'fromMacro', False),
- ('macro-first', 'macroFirst', False),
+ ("name", "buildName", "version.txt"),
+ ("template", "macroTemplate", "#${BUILD_NUMBER}"),
+ ("file", "fromFile", False),
+ ("macro", "fromMacro", False),
+ ("macro-first", "macroFirst", False),
]
- helpers.convert_mapping_to_xml(
- build_name_setter, data, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(build_name_setter, data, mapping, fail_required=True)
def nexus_artifact_uploader(registry, xml_parent, data):
@@ -4225,25 +4189,26 @@ def nexus_artifact_uploader(registry, xml_parent, data):
:language: yaml
"""
nexus_artifact_uploader = XML.SubElement(
- xml_parent,
- 'sp.sd.nexusartifactuploader.NexusArtifactUploader')
+ xml_parent, "sp.sd.nexusartifactuploader.NexusArtifactUploader"
+ )
mapping = [
- ('protocol', 'protocol', 'https'),
- ('nexus_url', 'nexusUrl', ''),
- ('nexus_user', 'nexusUser', ''),
- ('nexus_password', 'nexusPassword', ''),
- ('group_id', 'groupId', ''),
- ('artifact_id', 'artifactId', ''),
- ('version', 'version', ''),
- ('packaging', 'packaging', ''),
- ('type', 'type', ''),
- ('classifier', 'classifier', ''),
- ('repository', 'repository', ''),
- ('file', 'file', ''),
- ('credentials_id', 'credentialsId', ''),
+ ("protocol", "protocol", "https"),
+ ("nexus_url", "nexusUrl", ""),
+ ("nexus_user", "nexusUser", ""),
+ ("nexus_password", "nexusPassword", ""),
+ ("group_id", "groupId", ""),
+ ("artifact_id", "artifactId", ""),
+ ("version", "version", ""),
+ ("packaging", "packaging", ""),
+ ("type", "type", ""),
+ ("classifier", "classifier", ""),
+ ("repository", "repository", ""),
+ ("file", "file", ""),
+ ("credentials_id", "credentialsId", ""),
]
helpers.convert_mapping_to_xml(
- nexus_artifact_uploader, data, mapping, fail_required=True)
+ nexus_artifact_uploader, data, mapping, fail_required=True
+ )
def nexus_iq_policy_evaluator(registry, xml_parent, data):
@@ -4285,55 +4250,60 @@ def nexus_iq_policy_evaluator(registry, xml_parent, data):
:language: yaml
"""
nexus_iq_policy_evaluator = XML.SubElement(
- xml_parent,
- 'org.sonatype.nexus.ci.iq.IqPolicyEvaluatorBuildStep')
+ xml_parent, "org.sonatype.nexus.ci.iq.IqPolicyEvaluatorBuildStep"
+ )
format_dict = {
- 'stage': 'com__sonatype__nexus__ci__iq__IqPolicyEvaluator____iqStage',
- 'fone': 'com__sonatype__nexus__ci__iq__IqPolicyEvaluator'
- '____failBuildOnNetworkError',
+ "stage": "com__sonatype__nexus__ci__iq__IqPolicyEvaluator____iqStage",
+ "fone": "com__sonatype__nexus__ci__iq__IqPolicyEvaluator"
+ "____failBuildOnNetworkError",
}
- valid_stages = ['build', 'release', 'stage-release', 'operate']
+ valid_stages = ["build", "release", "stage-release", "operate"]
mapping = [
- ('stage', format_dict.get('stage'), None, valid_stages),
- ('fail-build-network-error', format_dict.get('fone'), False),
+ ("stage", format_dict.get("stage"), None, valid_stages),
+ ("fail-build-network-error", format_dict.get("fone"), False),
]
helpers.convert_mapping_to_xml(
- nexus_iq_policy_evaluator, data, mapping, fail_required=True)
+ nexus_iq_policy_evaluator, data, mapping, fail_required=True
+ )
- application_type_label = data.get('application-type', 'manual').lower()
+ application_type_label = data.get("application-type", "manual").lower()
application_type_label_dict = {
- 'manual': 'org.sonatype.nexus.ci.iq.ManualApplication',
- 'selected': 'org.sonatype.nexus.ci.iq.SelectedApplication',
+ "manual": "org.sonatype.nexus.ci.iq.ManualApplication",
+ "selected": "org.sonatype.nexus.ci.iq.SelectedApplication",
}
if application_type_label not in application_type_label_dict:
- raise InvalidAttributeError(application_type_label,
- application_type_label,
- application_type_label_dict.keys())
+ raise InvalidAttributeError(
+ application_type_label,
+ application_type_label,
+ application_type_label_dict.keys(),
+ )
application_type_tag = XML.SubElement(
nexus_iq_policy_evaluator,
- 'com__sonatype__nexus__ci__iq__IqPolicyEvaluator____iqApplication')
+ "com__sonatype__nexus__ci__iq__IqPolicyEvaluator____iqApplication",
+ )
application_type_tag.set(
"class", application_type_label_dict[application_type_label]
)
- mapping = [
- ('application-id', 'applicationId', None),
- ]
- helpers.convert_mapping_to_xml(application_type_tag, data,
- mapping, fail_required=True)
+ mapping = [("application-id", "applicationId", None)]
+ helpers.convert_mapping_to_xml(
+ application_type_tag, data, mapping, fail_required=True
+ )
- scan_pattern_list = data.get('scan-patterns', [])
- iq_scan_pattern_tag = XML.SubElement(nexus_iq_policy_evaluator,
- 'com__sonatype__nexus__ci__iq'
- '__IqPolicyEvaluator____iqScanPatterns')
+ scan_pattern_list = data.get("scan-patterns", [])
+ iq_scan_pattern_tag = XML.SubElement(
+ nexus_iq_policy_evaluator,
+ "com__sonatype__nexus__ci__iq" "__IqPolicyEvaluator____iqScanPatterns",
+ )
for scan_pattern in scan_pattern_list:
scan_pattern_tag = XML.SubElement(
- iq_scan_pattern_tag, 'org.sonatype.nexus.ci.iq.ScanPattern')
- XML.SubElement(scan_pattern_tag, 'scanPattern').text = scan_pattern
+ iq_scan_pattern_tag, "org.sonatype.nexus.ci.iq.ScanPattern"
+ )
+ XML.SubElement(scan_pattern_tag, "scanPattern").text = scan_pattern
def nexus_repo_manager(registry, xml_parent, data):
@@ -4352,15 +4322,16 @@ def nexus_repo_manager(registry, xml_parent, data):
/../../tests/builders/fixtures/nexus-repo-manager-minimal.yaml
:language: yaml
"""
- nexus_repo_manager = XML.SubElement(xml_parent,
- 'org.sonatype.nexus.ci.'
- 'nxrm.NexusPublisherBuildStep')
+ nexus_repo_manager = XML.SubElement(
+ xml_parent, "org.sonatype.nexus.ci." "nxrm.NexusPublisherBuildStep"
+ )
mapping = [
- ('instance-id', 'nexusInstanceId', None),
- ('repo-id', 'nexusRepositoryId', None),
+ ("instance-id", "nexusInstanceId", None),
+ ("repo-id", "nexusRepositoryId", None),
]
- helpers.convert_mapping_to_xml(nexus_repo_manager,
- data, mapping, fail_required=True)
+ helpers.convert_mapping_to_xml(
+ nexus_repo_manager, data, mapping, fail_required=True
+ )
def ansible_playbook(parser, xml_parent, data):
@@ -4434,88 +4405,91 @@ def ansible_playbook(parser, xml_parent, data):
:language: yaml
"""
plugin = XML.SubElement(
- xml_parent,
- 'org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder')
+ xml_parent, "org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder"
+ )
try:
- XML.SubElement(plugin, 'playbook').text = str(data['playbook'])
+ XML.SubElement(plugin, "playbook").text = str(data["playbook"])
except KeyError as ex:
raise MissingAttributeError(ex)
- inventory_types = ('path', 'content', 'do-not-specify')
- inventory_type = str(
- data.get('inventory-type', inventory_types[0])).lower()
+ inventory_types = ("path", "content", "do-not-specify")
+ inventory_type = str(data.get("inventory-type", inventory_types[0])).lower()
- inventory = XML.SubElement(plugin, 'inventory')
- inv_data = data.get('inventory', {})
- if inventory_type == 'path':
- inventory.set(
- 'class', 'org.jenkinsci.plugins.ansible.InventoryPath')
+ inventory = XML.SubElement(plugin, "inventory")
+ inv_data = data.get("inventory", {})
+ if inventory_type == "path":
+ inventory.set("class", "org.jenkinsci.plugins.ansible.InventoryPath")
try:
- path = inv_data['path']
+ path = inv_data["path"]
except KeyError:
- raise MissingAttributeError('inventory[\'path\']')
- XML.SubElement(inventory, 'path').text = path
- elif inventory_type == 'content':
- inventory.set(
- 'class', 'org.jenkinsci.plugins.ansible.InventoryContent')
+ raise MissingAttributeError("inventory['path']")
+ XML.SubElement(inventory, "path").text = path
+ elif inventory_type == "content":
+ inventory.set("class", "org.jenkinsci.plugins.ansible.InventoryContent")
try:
- content = inv_data['content']
+ content = inv_data["content"]
except KeyError:
- raise MissingAttributeError('inventory[\'content\']')
- XML.SubElement(inventory, 'content').text = content
- XML.SubElement(inventory, 'dynamic').text = str(
- inv_data.get('dynamic', False)).lower()
- elif inventory_type == 'do-not-specify':
- inventory.set(
- 'class', 'org.jenkinsci.plugins.ansible.InventoryDoNotSpecify')
+ raise MissingAttributeError("inventory['content']")
+ XML.SubElement(inventory, "content").text = content
+ XML.SubElement(inventory, "dynamic").text = str(
+ inv_data.get("dynamic", False)
+ ).lower()
+ elif inventory_type == "do-not-specify":
+ inventory.set("class", "org.jenkinsci.plugins.ansible.InventoryDoNotSpecify")
else:
- raise InvalidAttributeError(
- 'inventory-type', inventory_type, inventory_types)
- XML.SubElement(plugin, 'limit').text = data.get('hosts', '')
- XML.SubElement(plugin, 'tags').text = data.get('tags-to-run', '')
- XML.SubElement(plugin, 'skippedTags').text = data.get('tags-to-skip', '')
- XML.SubElement(plugin, 'startAtTask').text = data.get(
- 'task-to-start-at', '')
- XML.SubElement(plugin, 'credentialsId').text = data.get(
- 'credentials-id', '')
- XML.SubElement(plugin, 'vaultCredentialsId').text = data.get(
- 'vault-credentials-id', '')
- if data.get('sudo', False):
- XML.SubElement(plugin, 'sudo').text = 'true'
- XML.SubElement(plugin, 'sudoUser').text = data.get('sudo-user', '')
+ raise InvalidAttributeError("inventory-type", inventory_type, inventory_types)
+ XML.SubElement(plugin, "limit").text = data.get("hosts", "")
+ XML.SubElement(plugin, "tags").text = data.get("tags-to-run", "")
+ XML.SubElement(plugin, "skippedTags").text = data.get("tags-to-skip", "")
+ XML.SubElement(plugin, "startAtTask").text = data.get("task-to-start-at", "")
+ XML.SubElement(plugin, "credentialsId").text = data.get("credentials-id", "")
+ XML.SubElement(plugin, "vaultCredentialsId").text = data.get(
+ "vault-credentials-id", ""
+ )
+ if data.get("sudo", False):
+ XML.SubElement(plugin, "sudo").text = "true"
+ XML.SubElement(plugin, "sudoUser").text = data.get("sudo-user", "")
else:
- XML.SubElement(plugin, 'sudo').text = 'false'
- XML.SubElement(plugin, 'forks').text = str(data.get('workers', '5'))
- XML.SubElement(plugin, 'unbufferedOutput').text = str(
- data.get('unbuffered-output', True)).lower()
- XML.SubElement(plugin, 'colorizedOutput').text = str(
- data.get('colorized-output', False)).lower()
- XML.SubElement(plugin, 'hostKeyChecking').text = str(
- data.get('host-key-checking', False)).lower()
- XML.SubElement(plugin, 'additionalParameters').text = str(
- data.get('additional-parameters', ''))
+ XML.SubElement(plugin, "sudo").text = "false"
+ XML.SubElement(plugin, "forks").text = str(data.get("workers", "5"))
+ XML.SubElement(plugin, "unbufferedOutput").text = str(
+ data.get("unbuffered-output", True)
+ ).lower()
+ XML.SubElement(plugin, "colorizedOutput").text = str(
+ data.get("colorized-output", False)
+ ).lower()
+ XML.SubElement(plugin, "hostKeyChecking").text = str(
+ data.get("host-key-checking", False)
+ ).lower()
+ XML.SubElement(plugin, "additionalParameters").text = str(
+ data.get("additional-parameters", "")
+ )
# Following option is not available from UI
- XML.SubElement(plugin, 'copyCredentialsInWorkspace').text = 'false'
- variables = data.get('variables', [])
+ XML.SubElement(plugin, "copyCredentialsInWorkspace").text = "false"
+ variables = data.get("variables", [])
if variables:
if not is_sequence(variables):
raise InvalidAttributeError(
- 'variables', variables, 'list(dict(name, value, hidden))')
- variables_elm = XML.SubElement(plugin, 'extraVars')
+ "variables", variables, "list(dict(name, value, hidden))"
+ )
+ variables_elm = XML.SubElement(plugin, "extraVars")
for idx, values in enumerate(variables):
- if not hasattr(values, 'keys'):
+ if not hasattr(values, "keys"):
raise InvalidAttributeError(
- 'variables[%s]' % idx, values, 'dict(name, value, hidden)')
+ "variables[%s]" % idx, values, "dict(name, value, hidden)"
+ )
try:
- var_name = values['name']
+ var_name = values["name"]
except KeyError:
- raise MissingAttributeError('variables[%s][\'name\']' % idx)
+ raise MissingAttributeError("variables[%s]['name']" % idx)
value_elm = XML.SubElement(
- variables_elm, 'org.jenkinsci.plugins.ansible.ExtraVar')
- XML.SubElement(value_elm, 'key').text = var_name
- XML.SubElement(value_elm, 'value').text = values.get('value', '')
- XML.SubElement(value_elm, 'hidden').text = str(
- values.get('hidden', False)).lower()
+ variables_elm, "org.jenkinsci.plugins.ansible.ExtraVar"
+ )
+ XML.SubElement(value_elm, "key").text = var_name
+ XML.SubElement(value_elm, "value").text = values.get("value", "")
+ XML.SubElement(value_elm, "hidden").text = str(
+ values.get("hidden", False)
+ ).lower()
def nodejs(parser, xml_parent, data):
@@ -4541,20 +4515,18 @@ def nodejs(parser, xml_parent, data):
../../tests/builders/fixtures/nodejs-full.yaml
:language: yaml
"""
- nodejs = XML.SubElement(xml_parent,
- 'jenkins.plugins.nodejs.NodeJSCommandInterpreter')
- mapping = [
- ('script', 'command', None),
- ]
+ nodejs = XML.SubElement(
+ xml_parent, "jenkins.plugins.nodejs.NodeJSCommandInterpreter"
+ )
+ mapping = [("script", "command", None)]
mapping_opt = [
- ('name', 'nodeJSInstallationName', None),
- ('config-id', 'configId', None),
+ ("name", "nodeJSInstallationName", None),
+ ("config-id", "configId", None),
]
helpers.convert_mapping_to_xml(nodejs, data, mapping, fail_required=True)
- helpers.convert_mapping_to_xml(
- nodejs, data, mapping_opt, fail_required=False)
+ helpers.convert_mapping_to_xml(nodejs, data, mapping_opt, fail_required=False)
def xunit(registry, xml_parent, data):
@@ -4614,29 +4586,28 @@ def xunit(registry, xml_parent, data):
"""
logger = logging.getLogger(__name__)
- xunit = XML.SubElement(xml_parent,
- 'org.jenkinsci.plugins.xunit.XUnitBuilder')
- xunit.set('plugin', 'xunit')
+ xunit = XML.SubElement(xml_parent, "org.jenkinsci.plugins.xunit.XUnitBuilder")
+ xunit.set("plugin", "xunit")
# Map our internal types to the XML element names used by Jenkins plugin
types_to_plugin_types = {
- 'aunit': 'AUnitJunitHudsonTestType',
- 'boosttest': 'BoostTestJunitHudsonTestType',
- 'checktype': 'CheckType',
- 'cpptest': 'CppTestJunitHudsonTestType',
- 'cppunit': 'CppUnitJunitHudsonTestType',
- 'ctest': 'CTestType',
- 'dotnettest': 'XUnitDotNetTestType', # since plugin v1.93
- 'embunit': 'EmbUnitType', # since plugin v1.84
- 'fpcunit': 'FPCUnitJunitHudsonTestType',
- 'gtest': 'GoogleTestType',
- 'junit': 'JUnitType',
- 'mstest': 'MSTestJunitHudsonTestType',
- 'nunit': 'NUnitJunitHudsonTestType',
- 'phpunit': 'PHPUnitJunitHudsonTestType',
- 'tusar': 'TUSARJunitHudsonTestType',
- 'unittest': 'UnitTestJunitHudsonTestType',
- 'valgrind': 'ValgrindJunitHudsonTestType',
+ "aunit": "AUnitJunitHudsonTestType",
+ "boosttest": "BoostTestJunitHudsonTestType",
+ "checktype": "CheckType",
+ "cpptest": "CppTestJunitHudsonTestType",
+ "cppunit": "CppUnitJunitHudsonTestType",
+ "ctest": "CTestType",
+ "dotnettest": "XUnitDotNetTestType", # since plugin v1.93
+ "embunit": "EmbUnitType", # since plugin v1.84
+ "fpcunit": "FPCUnitJunitHudsonTestType",
+ "gtest": "GoogleTestType",
+ "junit": "JUnitType",
+ "mstest": "MSTestJunitHudsonTestType",
+ "nunit": "NUnitJunitHudsonTestType",
+ "phpunit": "PHPUnitJunitHudsonTestType",
+ "tusar": "TUSARJunitHudsonTestType",
+ "unittest": "UnitTestJunitHudsonTestType",
+ "valgrind": "ValgrindJunitHudsonTestType",
# FIXME should implement the 'custom' type
}
implemented_types = types_to_plugin_types.keys() # shortcut
@@ -4644,58 +4615,56 @@ def xunit(registry, xml_parent, data):
# Unit framework we are going to generate xml for
supported_types = []
- for configured_type in data['types']:
+ for configured_type in data["types"]:
type_name = next(iter(configured_type.keys()))
if type_name not in implemented_types:
- logger.warning("Requested xUnit type '%s' is not yet supported",
- type_name)
+ logger.warning("Requested xUnit type '%s' is not yet supported", type_name)
else:
# Append for generation
supported_types.append(configured_type)
# Generate XML for each of the supported framework types
- xmltypes = XML.SubElement(xunit, 'types')
+ xmltypes = XML.SubElement(xunit, "types")
mappings = [
- ('pattern', 'pattern', ''),
- ('requireupdate', 'failIfNotNew', True),
- ('deleteoutput', 'deleteOutputFiles', True),
- ('skip-if-no-test-files', 'skipNoTestFiles', False),
- ('stoponerror', 'stopProcessingIfError', True),
+ ("pattern", "pattern", ""),
+ ("requireupdate", "failIfNotNew", True),
+ ("deleteoutput", "deleteOutputFiles", True),
+ ("skip-if-no-test-files", "skipNoTestFiles", False),
+ ("stoponerror", "stopProcessingIfError", True),
]
for supported_type in supported_types:
framework_name = next(iter(supported_type.keys()))
- xmlframework = XML.SubElement(xmltypes,
- types_to_plugin_types[framework_name])
+ xmlframework = XML.SubElement(xmltypes, types_to_plugin_types[framework_name])
- helpers.convert_mapping_to_xml(xmlframework,
- supported_type[framework_name],
- mappings,
- fail_required=True)
+ helpers.convert_mapping_to_xml(
+ xmlframework, supported_type[framework_name], mappings, fail_required=True
+ )
- xmlthresholds = XML.SubElement(xunit, 'thresholds')
- for t in data.get('thresholds', []):
- if not ('failed' in t or 'skipped' in t):
- logger.warning(
- "Unrecognized threshold, should be 'failed' or 'skipped'")
+ xmlthresholds = XML.SubElement(xunit, "thresholds")
+ for t in data.get("thresholds", []):
+ if not ("failed" in t or "skipped" in t):
+ logger.warning("Unrecognized threshold, should be 'failed' or 'skipped'")
continue
- elname = ("org.jenkinsci.plugins.xunit.threshold.%sThreshold" %
- next(iter(t.keys())).title())
+ elname = (
+ "org.jenkinsci.plugins.xunit.threshold.%sThreshold"
+ % next(iter(t.keys())).title()
+ )
el = XML.SubElement(xmlthresholds, elname)
for threshold_name, threshold_value in next(iter(t.values())).items():
# Normalize and craft the element name for this threshold
- elname = "%sThreshold" % threshold_name.lower().replace(
- 'new', 'New')
+ elname = "%sThreshold" % threshold_name.lower().replace("new", "New")
XML.SubElement(el, elname).text = str(threshold_value)
# Whether to use percent of exact number of tests.
# Thresholdmode is either:
# - 1 : absolute (number of tests), default.
# - 2 : relative (percentage of tests)
- thresholdmode = '1'
- if 'percent' == data.get('thresholdmode', 'number'):
- thresholdmode = '2'
- XML.SubElement(xunit, 'thresholdMode').text = thresholdmode
-
- extra_config = XML.SubElement(xunit, 'extraConfiguration')
- XML.SubElement(extra_config, 'testTimeMargin').text = str(
- data.get('test-time-margin', '3000'))
+ thresholdmode = "1"
+ if "percent" == data.get("thresholdmode", "number"):
+ thresholdmode = "2"
+ XML.SubElement(xunit, "thresholdMode").text = thresholdmode
+
+ extra_config = XML.SubElement(xunit, "extraConfiguration")
+ XML.SubElement(extra_config, "testTimeMargin").text = str(
+ data.get("test-time-margin", "3000")
+ )