Skip to content
Permalink
Browse files

[FIXED JENKINS-20910] Added "Build parameters" column

  • Loading branch information
fredg02 committed Dec 16, 2013
1 parent eaa9a9d commit 2d0c0373755ae0aa85dbfbc74dab4b851dc32519
@@ -0,0 +1,91 @@
/*
* The MIT License
*
* Copyright (c) 2013, Frederic Gurr
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package jenkins.plugins.extracolumns;

import hudson.Extension;
import hudson.model.Action;
import hudson.model.ParameterValue;
import hudson.model.Job;
import hudson.model.ParametersAction;
import hudson.model.Run;
import hudson.views.ListViewColumnDescriptor;
import hudson.views.ListViewColumn;

import org.kohsuke.stapler.DataBoundConstructor;

public class BuildParametersColumn extends ListViewColumn {

private boolean isSinglePara;
private String parameterName;

@DataBoundConstructor
public BuildParametersColumn(boolean isSinglePara, String parameterName) {
super();
this.isSinglePara = isSinglePara;
this.parameterName = parameterName;
}

public BuildParametersColumn() {
this(false, "");
}

public boolean isSinglePara(){
return isSinglePara;
}

public String getBuildParameters(Job job) {
if (job == null || job.getLastBuild() == null) {
return "";
}
Run r = job.getLastBuild();
StringBuilder s = new StringBuilder();
for(Action action : r.getActions()) {
if(action instanceof ParametersAction) {
ParametersAction pa = (ParametersAction)action;
for (ParameterValue p : pa.getParameters()) {
if(!isSinglePara() || p.getName().equalsIgnoreCase(parameterName)){
s.append(p.getShortDescription()).append("<br/>");
}
}
}
}
return s.toString();
}

@Extension
public static class DescriptorImpl extends ListViewColumnDescriptor {

@Override
public boolean shownByDefault() {
return false;
}

@Override
public String getDisplayName() {
return Messages.BuildParametersColumn_DisplayName();
}

}
}
@@ -0,0 +1,31 @@
<!--
The MIT License
Copyright (c) 2013, Frederic Gurr
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core">
<j:set var="buildParameters" value="${it.getBuildParameters(job)}"/>
<td>
<j:out value="${buildParameters}" />
</td>
</j:jelly>
@@ -0,0 +1,30 @@
<!--
The MIT License
Copyright (c) 2013, Frederic Gurr
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core">
<th>
${%Build Parameters}
</th>
</j:jelly>
@@ -0,0 +1,25 @@
#
# The MIT License
#
# Copyright (c) 2013, Frederic Gurr
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

Build\ Parameters=Buildparameter
@@ -0,0 +1,37 @@
<!--
The MIT License
Copyright (c) 2013, Frederic Gurr
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:block>
<p>${%This column shows a single build parameter or all build parameters of the current/last build.}</p>
<f:optionalBlock field="isSinglePara" title="${%Show single parameter}" inline="true">
<f:entry title="${%Parameter name}">
<f:textbox field="parameterName" default="" />
</f:entry>
</f:optionalBlock>
</f:block>
</j:jelly>
@@ -0,0 +1,25 @@
# The MIT License
#
# Copyright (c) 2013, Frederic Gurr
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

This\ column\ shows\ a\ single\ build\ parameter\ or\ all\ build\ parameters\ of\ the\ current/last\ build.=Diese Spalte zeigt einen einzigen Buildparameter oder alle Buildparameter des aktuellen/letzten Builds an.
Show\ single\ parameter=Zeige nur einen Buildparameter an
Parameter\ name=Parametername
@@ -36,3 +36,4 @@ JobTypeColumn.FreestyleName=Free-style
JobTypeColumn.ExternalName=External
JobTypeColumn.FolderName=Folder
BuildDurationColumn.DisplayName=Build Duration
BuildParametersColumn.DisplayName=Build Parameters
@@ -29,4 +29,5 @@ SCMTypeColumn.DisplayName=SCM Typ
LastBuildConsoleColumn.DisplayName=Konsolenausgabe des letzten/aktuellen Builds
JobTypeColumn.DisplayName=Job Typ
JobTypeColumn.FolderName=Ordner
BuildDurationColumn.DisplayName=Builddauer
BuildDurationColumn.DisplayName=Builddauer
BuildParametersColumn.DisplayName=Buildparameter

0 comments on commit 2d0c037

Please sign in to comment.