Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'JENKINS-21037' of
https://github.com/krulls/extra-columns-plugin

Conflicts:
	src/main/resources/jenkins/plugins/extracolumns/Messages.properties
	src/main/resources/jenkins/plugins/extracolumns/Messages_de.properties
  • Loading branch information
fredg02 committed Dec 19, 2013
2 parents 6928f96 + 5a8a25c commit 59ee6cc
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 1 deletion.
85 changes: 85 additions & 0 deletions src/main/java/jenkins/plugins/extracolumns/SlaveOrLabelColumn.java
@@ -0,0 +1,85 @@
/*
* The MIT License
*
* Copyright (c) 2013, Stephan Krull
*
* 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.AbstractProject;
import hudson.model.Job;
import hudson.model.Label;
import hudson.views.ListViewColumnDescriptor;
import hudson.views.ListViewColumn;

import java.util.logging.Logger;

import org.kohsuke.stapler.DataBoundConstructor;

/**
* View column that shows build processor or build processor label restriction
* of a job.
*
* @author krulls
*/
public class SlaveOrLabelColumn extends ListViewColumn {

private static final Logger LOGGER = Logger
.getLogger(SlaveOrLabelColumn.class.getName());

@DataBoundConstructor
public SlaveOrLabelColumn() {
}

public String getInfo(Job<?, ?> job) {

if(!(job instanceof AbstractProject)){
LOGGER.finest("Not an instance of " + AbstractProject.class.getCanonicalName() + ". Cannot get info.");
return "";
}

AbstractProject<?, ?> project = AbstractProject.class.cast(job);
Label projectLabel = project.getAssignedLabel();
if (projectLabel == null || projectLabel.isEmpty())
return "N/A";

if (projectLabel.isSelfLabel())
return projectLabel.getName();

return projectLabel.getName()
+ ((projectLabel.getDescription() == null || projectLabel
.getDescription().length() < 1) ? "" : " ("
+ projectLabel.getDescription() + ")");
}

@Extension
public static class DescriptorImpl extends ListViewColumnDescriptor {
@Override
public String getDisplayName() {
return Messages.SlaveOrLabelColumn_DisplayName();
}

@Override
public boolean shownByDefault() {
return false;
}
}
}
Expand Up @@ -38,3 +38,4 @@ JobTypeColumn.FolderName=Folder
BuildDurationColumn.DisplayName=Build Duration
BuildParametersColumn.DisplayName=Build Parameters
LastJobConfigurationModificationColumn.DisplayName=Last Configuration Modification
SlaveOrLabelColumn.DisplayName=Slave Allocation
Expand Up @@ -31,4 +31,5 @@ JobTypeColumn.DisplayName=Job Typ
JobTypeColumn.FolderName=Ordner
BuildDurationColumn.DisplayName=Builddauer
BuildParametersColumn.DisplayName=Buildparameter
LastJobConfigurationModificationColumn.DisplayName=Letzte Änderung der Konfiguration
LastJobConfigurationModificationColumn.DisplayName=Letzte Änderung der Konfiguration
SlaveOrLabelColumn.DisplayName=Knotenzuordnung
@@ -0,0 +1,27 @@
<!--
The MIT License
Copyright (c) 2013, Stephan Krull
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.
-->

<j:jelly xmlns:j="jelly:core">
<td data="${it.getInfo(job)}">${it.getInfo(job)}</td>
</j:jelly>
@@ -0,0 +1,27 @@
<!--
The MIT License
Copyright (c) 2013, Stephan Krull
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.
-->

<j:jelly xmlns:j="jelly:core">
<th>${%SOL Column}</th>
</j:jelly>
@@ -0,0 +1 @@
SOL\ Column=Slave Allocation
@@ -0,0 +1 @@
SOL\ Column=Knotenzuordnung

0 comments on commit 59ee6cc

Please sign in to comment.