Skip to content

Commit

Permalink
Add LastBuildNodeColumn
Browse files Browse the repository at this point in the history
Replaces Build Node Column Plugin by Takahisa Wada, includes potential
fix for JENKINS-21870
  • Loading branch information
fredg02 committed Dec 10, 2015
1 parent 12897ff commit 3a95245
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 0 deletions.
@@ -0,0 +1,73 @@
/*
* The MIT License
*
* Copyright (c) 2015, 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 jenkins.model.Jenkins;

import org.kohsuke.stapler.DataBoundConstructor;

import hudson.Extension;
import hudson.model.AbstractBuild;
import hudson.model.Job;
import hudson.model.Node;
import hudson.model.Run;
import hudson.views.ListViewColumn;
import hudson.views.ListViewColumnDescriptor;

public class LastBuildNodeColumn extends ListViewColumn {

@DataBoundConstructor
public LastBuildNodeColumn() {
super();
}

public String getLastBuildNode(Job<?, ?> job) {
Run<?, ?> lastBuild = job.getLastBuild();
if (lastBuild == null) {
return null;
}
Node builtOn = ((AbstractBuild<?, ?>) lastBuild).getBuiltOn();
if (builtOn instanceof Jenkins) {
return "master";
}
return builtOn.getDisplayName();
}

@Extension
public static class DescriptorImpl extends ListViewColumnDescriptor {

public DescriptorImpl() {
}

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

@Override
public boolean shownByDefault() {
return false;
}
}
}
@@ -0,0 +1,41 @@
<!--
The MIT License
Copyright (c) 2015, 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">
<td>
<j:set var="node" value="${it.getLastBuildNode(job)}" />
<j:choose>
<j:when test="${'master'eq node}">
<a href="${rootURL}/computer/(master)">Master</a>
</j:when>
<j:when test="${node == null}">
<span>N/A</span>
</j:when>
<j:otherwise>
<a href="${rootURL}/computer/${node}">${node}</a>
</j:otherwise>
</j:choose>
</td>
</j:jelly>
@@ -0,0 +1,28 @@
<!--
The MIT License
Copyright (c) 2015, 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>${%Last Build Node}</th>
</j:jelly>
@@ -0,0 +1,25 @@
#
# The MIT License
#
# Copyright (c) 2015, 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.
#

Last\ Build\ Node=Letzter Build Node
@@ -0,0 +1,37 @@
<!--
The MIT License
Copyright (c) 2015, 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:f="/lib/form">
<f:block>
<tr>
<td width="50">
<img src="${imagesURL}/48x48/computer.png" title="${%Last build node icon}" alt="${%Last build node icon}" border="0"/>
</td>
<td colspan="2">
<p>${%This column shows the name of the node on which the last build was executed.}</p>
</td>
</tr>
</f:block>
</j:jelly>
@@ -0,0 +1,24 @@
# The MIT License
#
# Copyright (c) 2015, 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\ the\ name\ of\ the\ node\ on\ which\ the\ last\ build\ was\ executed.=Diese Spalte zeigt den Namen des Knoten an auf dem der letzte Build ausgeführt wurde.
Last\ build\ node\ icon=Letzer Build Node Icon
Expand Up @@ -28,6 +28,7 @@ TestResultColumn.DisplayName=Test Result
SCMTypeColumn.DisplayName=SCM Type
LastBuildConsoleColumn.DisplayName=Last/Current Build Console Output
WorkspaceColumn.DisplayName=Workspace
LastBuildNodeColumn.DisplayName=Last Build Node
JobTypeColumn.DisplayName=Job Type
JobTypeColumn.MavenName=Maven
JobTypeColumn.MultiJobName=MultiJob
Expand Down
Expand Up @@ -34,3 +34,4 @@ BuildDurationColumn.DisplayName=Builddauer
BuildParametersColumn.DisplayName=Buildparameter
LastJobConfigurationModificationColumn.DisplayName=Letzte Änderung der Konfiguration
SlaveOrLabelColumn.DisplayName=Knotenzuordnung
LastBuildNodeColumn.DisplayName=Letzter Build Knoten

0 comments on commit 3a95245

Please sign in to comment.