Skip to content

Commit

Permalink
JENKINS-21035: implementation last job configuration modification
Browse files Browse the repository at this point in the history
  • Loading branch information
krulls committed Dec 19, 2013
1 parent b293fb6 commit 6928f96
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 1 deletion.
@@ -0,0 +1,87 @@
/*
* 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.XmlFile;
import hudson.model.Job;
import hudson.views.ListViewColumnDescriptor;
import hudson.views.ListViewColumn;

import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.lang.time.FastDateFormat;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* View column that shows the date of last job configuration modification.
*
* @author Stephan Krull, ECG Leipzig GmbH
*
*/
public class LastJobConfigurationModificationColumn extends ListViewColumn {

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

@DataBoundConstructor
public LastJobConfigurationModificationColumn() {
}

public String getInfo(Job<?, ?> job) {
XmlFile config = job.getConfigFile();
if (config == null || !config.exists())
return "N/A";

try {
long lm = config.getFile().lastModified();
return FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss").format(
new Date(lm));
} catch (Exception e) {
LOGGER.log(Level.WARNING,
"Cannot read last modification date of configuration for job '"
+ job.getName() + "'.", e);
return "N/A";
}

}

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

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

}
}
@@ -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>${%CLM Column}</th>
</j:jelly>
@@ -0,0 +1 @@
CLM\ Column=Last Configuration Change
@@ -0,0 +1 @@
CLM\ Column=Letzte Änderung an Job Konfiguration
Expand Up @@ -37,3 +37,4 @@ JobTypeColumn.ExternalName=External
JobTypeColumn.FolderName=Folder
BuildDurationColumn.DisplayName=Build Duration
BuildParametersColumn.DisplayName=Build Parameters
LastJobConfigurationModificationColumn.DisplayName=Last Configuration Modification
Expand Up @@ -30,4 +30,5 @@ LastBuildConsoleColumn.DisplayName=Konsolenausgabe des letzten/aktuellen Builds
JobTypeColumn.DisplayName=Job Typ
JobTypeColumn.FolderName=Ordner
BuildDurationColumn.DisplayName=Builddauer
BuildParametersColumn.DisplayName=Buildparameter
BuildParametersColumn.DisplayName=Buildparameter
LastJobConfigurationModificationColumn.DisplayName=Letzte Änderung der Konfiguration

0 comments on commit 6928f96

Please sign in to comment.