Add support for few of Extra Columns plugin' extra columns for ListView generator
Changes include support for TestResultColumn, BuildDescriptionColumn, BuildParametersColumn, UserNameColumn, LastBuildConsoleColumn, WorkspaceColumn and ConfigureProjectColumn. Updated examples to show up how to use new columns with list view builder. Proposed column names in job generation YAML config file are: - extra-tests-total - extra-tests-failed - extra-tests-passed - extra-tests-skipped - extra-tests-format-0 - extra-tests-format-1 - extra-build-parameters - extra-build-description - extra-last-user-name - extra-workspace-link - extra-configure-button - extra-last-output To add an extra column with specific parameter named MY_PARAMETER, use following syntax: - extra-build-parameter: MY_PARAMETER Change-Id: I9497e2e322027f8cda105d728ee3d105a19b206e
This commit is contained in:
parent
5a1150b65a
commit
0411adde25
@ -226,7 +226,6 @@ import jenkins_jobs.modules.base
|
||||
|
||||
from jenkins_jobs.modules.helpers import convert_mapping_to_xml
|
||||
|
||||
|
||||
COLUMN_DICT = {
|
||||
'status': 'hudson.views.StatusColumn',
|
||||
'weather': 'hudson.views.WeatherColumn',
|
||||
@ -251,6 +250,50 @@ COLUMN_DICT = {
|
||||
'member-graph-view':
|
||||
'com.barchart.jenkins.cascade.GraphViewColumn '
|
||||
'plugin="maven-release-cascade"',
|
||||
'extra-tests-total': [
|
||||
['jenkins.plugins.extracolumns.TestResultColumn',
|
||||
{'plugin': 'extra-columns'}],
|
||||
'<testResultFormat>2</testResultFormat>'],
|
||||
'extra-tests-failed': [
|
||||
['jenkins.plugins.extracolumns.TestResultColumn',
|
||||
{'plugin': 'extra-columns'}],
|
||||
'<testResultFormat>3</testResultFormat>'],
|
||||
'extra-tests-passed': [
|
||||
['jenkins.plugins.extracolumns.TestResultColumn',
|
||||
{'plugin': 'extra-columns'}],
|
||||
'<testResultFormat>4</testResultFormat>'],
|
||||
'extra-tests-skipped': [
|
||||
['jenkins.plugins.extracolumns.TestResultColumn',
|
||||
{'plugin': 'extra-columns'}],
|
||||
'<testResultFormat>5</testResultFormat>'],
|
||||
'extra-tests-format-0': [
|
||||
['jenkins.plugins.extracolumns.TestResultColumn',
|
||||
{'plugin': 'extra-columns'}],
|
||||
'<testResultFormat>0</testResultFormat>'],
|
||||
'extra-tests-format-1': [
|
||||
['jenkins.plugins.extracolumns.TestResultColumn',
|
||||
{'plugin': 'extra-columns'}],
|
||||
'<testResultFormat>1</testResultFormat>'],
|
||||
'extra-build-description': [
|
||||
['jenkins.plugins.extracolumns.BuildDescriptionColumn',
|
||||
{'plugin': 'extra-columns'}],
|
||||
'<columnWidth>3</columnWidth>', '<forceWidth>false</forceWidth>'],
|
||||
'extra-build-parameters': [
|
||||
['jenkins.plugins.extracolumns.BuildParametersColumn',
|
||||
{'plugin': 'extra-columns'}],
|
||||
'<singlePara>false</singlePara>', '<parameterName/>'],
|
||||
'extra-last-user-name':
|
||||
'jenkins.plugins.extracolumns.UserNameColumn'
|
||||
' plugin="extra-columns"',
|
||||
'extra-last-output':
|
||||
'jenkins.plugins.extracolumns.LastBuildConsoleColumn'
|
||||
' plugin="extra-columns"',
|
||||
'extra-workspace-link':
|
||||
'jenkins.plugins.extracolumns.WorkspaceColumn '
|
||||
'plugin="extra-columns"',
|
||||
'extra-configure-button':
|
||||
'jenkins.plugins.extracolumns.ConfigureProjectColumn'
|
||||
' plugin="extra-columns"',
|
||||
}
|
||||
DEFAULT_COLUMNS = ['status', 'weather', 'job', 'last-success', 'last-failure',
|
||||
'last-duration', 'build-button']
|
||||
@ -274,8 +317,12 @@ class List(jenkins_jobs.modules.base.Base):
|
||||
|
||||
jn_xml = XML.SubElement(root, 'jobNames')
|
||||
jobnames = data.get('job-name', None)
|
||||
XML.SubElement(jn_xml, 'comparator', {'class':
|
||||
'hudson.util.CaseInsensitiveComparator'})
|
||||
XML.SubElement(
|
||||
jn_xml,
|
||||
'comparator', {
|
||||
'class': 'hudson.util.CaseInsensitiveComparator'
|
||||
}
|
||||
)
|
||||
if jobnames is not None:
|
||||
jobnames = sorted(jobnames) # Job names must be sorted in the xml
|
||||
for jobname in jobnames:
|
||||
@ -348,8 +395,10 @@ class List(jenkins_jobs.modules.base.Base):
|
||||
fail_required=True)
|
||||
|
||||
if jobfilter == 'upstream-downstream':
|
||||
ud_xml = XML.SubElement(job_filter_xml,
|
||||
'hudson.views.UpstreamDownstreamJobsFilter')
|
||||
ud_xml = XML.SubElement(
|
||||
job_filter_xml,
|
||||
'hudson.views.UpstreamDownstreamJobsFilter'
|
||||
)
|
||||
ud_xml.set('plugin', 'view-job-filters')
|
||||
ud_data = jobfilters.get('upstream-downstream')
|
||||
mapping = [
|
||||
@ -363,8 +412,10 @@ class List(jenkins_jobs.modules.base.Base):
|
||||
fail_required=True)
|
||||
|
||||
if jobfilter == 'fallback':
|
||||
fb_xml = XML.SubElement(job_filter_xml,
|
||||
'hudson.views.AddRemoveFallbackFilter')
|
||||
fb_xml = XML.SubElement(
|
||||
job_filter_xml,
|
||||
'hudson.views.AddRemoveFallbackFilter'
|
||||
)
|
||||
fb_xml.set('plugin', 'view-job-filters')
|
||||
fb_data = jobfilters.get('fallback')
|
||||
mapping = [
|
||||
@ -534,7 +585,26 @@ class List(jenkins_jobs.modules.base.Base):
|
||||
columns = data.get('columns', DEFAULT_COLUMNS)
|
||||
|
||||
for column in columns:
|
||||
if isinstance(column, dict):
|
||||
if 'extra-build-parameter' in column:
|
||||
p_name = column['extra-build-parameter']
|
||||
x = XML.SubElement(
|
||||
c_xml,
|
||||
'jenkins.plugins.extracolumns.BuildParametersColumn',
|
||||
plugin='extra-columns'
|
||||
)
|
||||
x.append(XML.fromstring(
|
||||
'<singlePara>true</singlePara>'))
|
||||
x.append(XML.fromstring(
|
||||
'<parameterName>%s</parameterName>' % p_name))
|
||||
else:
|
||||
if column in COLUMN_DICT:
|
||||
if isinstance(COLUMN_DICT[column], list):
|
||||
x = XML.SubElement(c_xml, COLUMN_DICT[column][0][0],
|
||||
**COLUMN_DICT[column][0][1])
|
||||
for tag in COLUMN_DICT[column][1:]:
|
||||
x.append(XML.fromstring(tag))
|
||||
else:
|
||||
XML.SubElement(c_xml, COLUMN_DICT[column])
|
||||
mapping = [
|
||||
('regex', 'includeRegex', None),
|
||||
|
@ -31,6 +31,36 @@
|
||||
<jenkins.branch.DescriptionColumn/>
|
||||
<com.sonatype.insight.ci.hudson.QualityColumn plugin="sonatype-clm-ci"/>
|
||||
<com.barchart.jenkins.cascade.GraphViewColumn plugin="maven-release-cascade"/>
|
||||
<jenkins.plugins.extracolumns.TestResultColumn plugin="extra-columns">
|
||||
<testResultFormat>2</testResultFormat>
|
||||
</jenkins.plugins.extracolumns.TestResultColumn>
|
||||
<jenkins.plugins.extracolumns.TestResultColumn plugin="extra-columns">
|
||||
<testResultFormat>3</testResultFormat>
|
||||
</jenkins.plugins.extracolumns.TestResultColumn>
|
||||
<jenkins.plugins.extracolumns.TestResultColumn plugin="extra-columns">
|
||||
<testResultFormat>4</testResultFormat>
|
||||
</jenkins.plugins.extracolumns.TestResultColumn>
|
||||
<jenkins.plugins.extracolumns.TestResultColumn plugin="extra-columns">
|
||||
<testResultFormat>5</testResultFormat>
|
||||
</jenkins.plugins.extracolumns.TestResultColumn>
|
||||
<jenkins.plugins.extracolumns.TestResultColumn plugin="extra-columns">
|
||||
<testResultFormat>0</testResultFormat>
|
||||
</jenkins.plugins.extracolumns.TestResultColumn>
|
||||
<jenkins.plugins.extracolumns.TestResultColumn plugin="extra-columns">
|
||||
<testResultFormat>1</testResultFormat>
|
||||
</jenkins.plugins.extracolumns.TestResultColumn>
|
||||
<jenkins.plugins.extracolumns.BuildParametersColumn plugin="extra-columns">
|
||||
<singlePara>false</singlePara>
|
||||
<parameterName/>
|
||||
</jenkins.plugins.extracolumns.BuildParametersColumn>
|
||||
<jenkins.plugins.extracolumns.BuildDescriptionColumn plugin="extra-columns">
|
||||
<columnWidth>3</columnWidth>
|
||||
<forceWidth>false</forceWidth>
|
||||
</jenkins.plugins.extracolumns.BuildDescriptionColumn>
|
||||
<jenkins.plugins.extracolumns.UserNameColumn plugin="extra-columns"/>
|
||||
<jenkins.plugins.extracolumns.WorkspaceColumn plugin="extra-columns"/>
|
||||
<jenkins.plugins.extracolumns.ConfigureProjectColumn plugin="extra-columns"/>
|
||||
<jenkins.plugins.extracolumns.LastBuildConsoleColumn plugin="extra-columns"/>
|
||||
</columns>
|
||||
<recurse>true</recurse>
|
||||
<statusFilter>false</statusFilter>
|
||||
|
@ -26,5 +26,17 @@ columns:
|
||||
- desc
|
||||
- policy-violations
|
||||
- member-graph-view
|
||||
- extra-tests-total
|
||||
- extra-tests-failed
|
||||
- extra-tests-passed
|
||||
- extra-tests-skipped
|
||||
- extra-tests-format-0
|
||||
- extra-tests-format-1
|
||||
- extra-build-parameters
|
||||
- extra-build-description
|
||||
- extra-last-user-name
|
||||
- extra-workspace-link
|
||||
- extra-configure-button
|
||||
- extra-last-output
|
||||
recurse: true
|
||||
status-filter: false
|
||||
|
@ -16,6 +16,10 @@
|
||||
<hudson.views.LastSuccessColumn/>
|
||||
<hudson.views.LastFailureColumn/>
|
||||
<hudson.views.LastDurationColumn/>
|
||||
<jenkins.plugins.extracolumns.BuildParametersColumn plugin="extra-columns">
|
||||
<singlePara>true</singlePara>
|
||||
<parameterName>MY_PARAMETER</parameterName>
|
||||
</jenkins.plugins.extracolumns.BuildParametersColumn>
|
||||
</columns>
|
||||
<includeRegex>(?!test.*).*</includeRegex>
|
||||
<recurse>false</recurse>
|
||||
|
@ -8,4 +8,5 @@ columns:
|
||||
- last-success
|
||||
- last-failure
|
||||
- last-duration
|
||||
- extra-build-parameter: MY_PARAMETER
|
||||
regex: (?!test.*).*
|
||||
|
Loading…
Reference in New Issue
Block a user