-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
see JENKINS-69063
- Loading branch information
Showing
6 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
src/main/java/hudson/plugins/logparser/LogParserColumn.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package hudson.plugins.logparser; | ||
|
||
import hudson.Extension; | ||
import hudson.model.Job; | ||
import hudson.model.Run; | ||
import hudson.views.ListViewColumn; | ||
import hudson.views.ListViewColumnDescriptor; | ||
import net.sf.json.JSONObject; | ||
import org.kohsuke.stapler.StaplerRequest; | ||
|
||
public class LogParserColumn extends ListViewColumn { | ||
public int[] getResult(Job job) { | ||
if (job == null) { | ||
return null; | ||
} | ||
Run build = job.getLastCompletedBuild(); | ||
if (build == null) { | ||
return null; | ||
} | ||
LogParserAction action = build.getAction(LogParserAction.class); | ||
if (action == null) { | ||
return null; | ||
} | ||
LogParserResult result = action.getResult(); | ||
if (result == null) { | ||
return null; | ||
} | ||
|
||
return new int[]{result.getTotalErrors(), result.getTotalWarnings(), result.getTotalInfos(), result.getTotalDebugs()}; | ||
} | ||
|
||
public String getUrl(Job job) { | ||
if (job == null) { | ||
return null; | ||
} | ||
Run build = job.getLastCompletedBuild(); | ||
if (build == null) { | ||
return null; | ||
} | ||
return build.getUrl() + LogParserAction.getUrlNameStat(); | ||
} | ||
|
||
@Extension | ||
public static class LogParserColumnDescriptor extends ListViewColumnDescriptor { | ||
@Override | ||
public ListViewColumn newInstance(StaplerRequest req, JSONObject formData) throws FormException { | ||
return new LogParserColumn(); | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return Messages.LogParserColumn_Header(); | ||
} | ||
|
||
@Override | ||
public boolean shownByDefault() { | ||
return false; | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/resources/hudson/plugins/logparser/LogParserColumn/column.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<j:jelly xmlns:j="jelly:core"> | ||
<j:set var="result" value="${it.getResult(job)}"/> | ||
<j:set var="url" value="${it.getUrl(job)}"/> | ||
<td style="font-weight: bold"> | ||
<j:choose> | ||
<j:when test="${url == null}"> | ||
</j:when> | ||
<j:when test="${result == null}"> | ||
- | ||
</j:when> | ||
<j:otherwise> | ||
<a href="${rootURL}/${url}"> | ||
<span style="color: ${%Error.color}">${%Error}${result[0]};</span> | ||
<span style="color: ${%Warning.color}">${%Warning}${result[1]};</span> | ||
<span style="color: ${%Info.color}">${%Info}${result[2]};</span> | ||
<span style="color: ${%Debug.color}">${%Debug}${result[3]}</span> | ||
</a> | ||
</j:otherwise> | ||
</j:choose> | ||
</td> | ||
</j:jelly> |
9 changes: 9 additions & 0 deletions
9
src/main/resources/hudson/plugins/logparser/LogParserColumn/column.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Error=E: | ||
Warning=W: | ||
Info=I: | ||
Debug=D: | ||
|
||
Error.color=red | ||
Warning.color=orange | ||
Info.color=green | ||
Debug.color=gray |
3 changes: 3 additions & 0 deletions
3
src/main/resources/hudson/plugins/logparser/LogParserColumn/columnHeader.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<j:jelly xmlns:j="jelly:core"> | ||
<th>${%LogParserColumn.Header}</th> | ||
</j:jelly> |
1 change: 1 addition & 0 deletions
1
src/main/resources/hudson/plugins/logparser/LogParserColumn/columnHeader.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LogParserColumn.Header=Log parser |
1 change: 1 addition & 0 deletions
1
src/main/resources/hudson/plugins/logparser/Messages.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LogParserColumn.Header=Log parser |