Skip to content

Commit

Permalink
[FIXED JENKINS-31959] Add user name column
Browse files Browse the repository at this point in the history
  • Loading branch information
fredg02 committed Dec 10, 2015
1 parent 3a95245 commit 3c17fb0
Show file tree
Hide file tree
Showing 8 changed files with 223 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/main/java/jenkins/plugins/extracolumns/UserNameColumn.java
@@ -0,0 +1,66 @@
/*
* 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 org.kohsuke.stapler.DataBoundConstructor;

import hudson.Extension;
import hudson.model.Cause.UserIdCause;
import hudson.model.Job;
import hudson.model.Run;
import hudson.views.ListViewColumn;
import hudson.views.ListViewColumnDescriptor;

public class UserNameColumn extends ListViewColumn {

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

public UserIdCause getUserIdCause(Job<?, ?> job) {
Run<?, ?> lastBuild = job.getLastBuild();
if (lastBuild == null) {
return null;
}
return lastBuild.getCause(UserIdCause.class);
}

@Extension
public static class DescriptorImpl extends ListViewColumnDescriptor {

public DescriptorImpl() {
}

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

@Override
public boolean shownByDefault() {
return false;
}
}
}
Expand Up @@ -41,3 +41,4 @@ BuildDurationColumn.DisplayName=Build Duration
BuildParametersColumn.DisplayName=Build Parameters
LastJobConfigurationModificationColumn.DisplayName=Last Configuration Modification
SlaveOrLabelColumn.DisplayName=Slave Allocation
UserNameColumn.DisplayName=User Name
Expand Up @@ -35,3 +35,4 @@ BuildParametersColumn.DisplayName=Buildparameter
LastJobConfigurationModificationColumn.DisplayName=Letzte Änderung der Konfiguration
SlaveOrLabelColumn.DisplayName=Knotenzuordnung
LastBuildNodeColumn.DisplayName=Letzter Build Knoten
UserNameColumn.DisplayName=Benutername
@@ -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="userIdCause" value="${it.getUserIdCause(job)}" />
<j:choose>
<j:when test="${userIdCause == null}">
<span>N/A</span>
</j:when>
<j:when test="${userIdCause != null and (userIdCause.userId == null or userIdCause.userId eq '')}">
<a href="${rootURL}/user/${userIdCause.userName}" title="${userIdCause.userName}">${userIdCause.userName}</a>
</j:when>
<j:otherwise>
<a href="${rootURL}/user/${userIdCause.userId}" title="${userIdCause.userName} (${userIdCause.userId})">${userIdCause.userName}</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>${%User Name}</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.
#

User\ Name=Benutzername
@@ -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/user.png" title="${%User icon}" alt="${%User icon}" border="0"/>
</td>
<td colspan="2">
<p>${%This column shows the name of the user that started the last build.}</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\ user\ that\ started\ the\ last\ build.=Diese Spalte zeigt den Benutzer an, der den letzten Build gestartet hat.
User\ icon=Benutzer Icon

0 comments on commit 3c17fb0

Please sign in to comment.