Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
}

Map<TriggerDescriptor, Trigger<?>> triggers = null;
if (job instanceof AbstractProject) {
triggers = ((AbstractProject<?, ?>) job).getTriggers();
} if (job instanceof ParameterizedJobMixIn.ParameterizedJob) {
triggers = ((ParameterizedJobMixIn.ParameterizedJob)job).getTriggers();
if (job instanceof ParameterizedJobMixIn.ParameterizedJob<?, ?> pj) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An AbstractProject is a ParameterizedJobMixIn.ParameterizedJob so that can be simplified.

triggers = pj.getTriggers();

Check warning on line 65 in src/main/java/jenkins/plugins/extracolumns/CronTriggerColumn.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 64-65 are not covered by tests
}

if (triggers == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private String formatDescription(AbstractItem job, boolean trimIt) {
return "";
}

StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
if (!trimIt) {
sb.append(job.getDescription());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,29 @@

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

public String getLastBuildNodeDescription(Job<?, ?> job) {
Run<?, ?> lastBuild = job.getLastBuild();
if (lastBuild instanceof AbstractBuild<?, ?> ab) {
Node builtOn = ab.getBuiltOn();
if (builtOn != null) {
return builtOn.getNodeDescription();
}
}
return null;

Check warning on line 67 in src/main/java/jenkins/plugins/extracolumns/LastBuildNodeColumn.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 47-67 are not covered by tests
}

@Extension
public static class DescriptorImpl extends ListViewColumnDescriptor {

Expand Down
13 changes: 6 additions & 7 deletions src/main/java/jenkins/plugins/extracolumns/SCMTypeColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,21 @@
}

public String getScmType(@SuppressWarnings("rawtypes") Job job) {
if(job instanceof AbstractProject<?, ?>) {
AbstractProject<?, ?> project = (AbstractProject<?, ?>) job;
if(job instanceof AbstractProject<?, ?> project) {
return project.getScm().getDescriptor().getDisplayName();
} else {
String simpleName = job.getClass().getSimpleName();
if ("WorkflowJob".equals(simpleName)) {
Jenkins instance = Jenkins.getInstance();
if (instance != null && instance.getPlugin("workflow-job") != null) {
Jenkins instance = Jenkins.get();
if (instance.getPlugin("workflow-job") != null) {
org.jenkinsci.plugins.workflow.job.WorkflowJob wfj = (org.jenkinsci.plugins.workflow.job.WorkflowJob) job;
Collection<? extends SCM> scms = wfj.getSCMs();
if (scms.size() == 0) {
if (scms.isEmpty()) {
return "N/A";
}
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (SCM scm : scms) {
sb.append(scm.getDescriptor().getDisplayName() + "\n");
sb.append(scm.getDescriptor().getDisplayName()).append("\n");

Check warning on line 62 in src/main/java/jenkins/plugins/extracolumns/SCMTypeColumn.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 48-62 are not covered by tests
}
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,20 @@
}

public Label getLabel(Job<?, ?> job) {
if(!(job instanceof AbstractProject)){
if(!(job instanceof AbstractProject<?, ?> ap)){
LOGGER.finest("Not an instance of " + AbstractProject.class.getCanonicalName() + ". Cannot get info.");
return null;
}

AbstractProject<?, ?> project = AbstractProject.class.cast(job);
return project.getAssignedLabel();
return ap.getAssignedLabel();
}

public String getDescription(Label label) {
if (label == null) {
return "";
}
String desc = label.getDescription();
return (desc == null || desc.length() < 1) ? "" : "(" + desc + ")";
return (desc == null || desc.isEmpty()) ? "" : "(" + desc + ")";

Check warning on line 64 in src/main/java/jenkins/plugins/extracolumns/SlaveOrLabelColumn.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 51-64 are not covered by tests
}

@Extension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,11 @@
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:block>
<table>
<tr>
<td colspan="3">${%This column shows the build description of the last build.}</td>
</tr>
<f:optionalBlock field="forceWidth" title="${%Force column width}" inline="true">
<f:entry title="${%Column width}">
<f:textbox field="columnWidth" default="80" />
</f:entry>
</f:optionalBlock>
</table>
</f:block>
</j:jelly>
<f:entry title="${%This column shows the build description of the last build.}">
<f:optionalBlock field="forceWidth" title="${%Force column width}" inline="true">
<f:entry title="${%Column width}">
<f:textbox field="columnWidth" default="80" />
</f:entry>
</f:optionalBlock>
</f:entry>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ THE SOFTWARE.
</j:choose>
</j:when>
</j:choose>
<td data="${sortData}" tooltip="${naTooltip}">${buildDurationString}</td>
<td data="${sortData}"><span tooltip="${naTooltip}">${buildDurationString}</span></td>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ THE SOFTWARE.

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<f:block>
<p>${%This column shows the last build duration.}</p>
<div><p>${%This column shows the last build duration.}</p></div>
<f:entry title="${%Show}">
<select name="buildDurationType" class="setting-input">
<div class="jenkins-select">
<select name="buildDurationType" class="jenkins-select__input">
<f:option value="0" selected="${instance.buildDurationType==0}">${%Time since build started}</f:option>
<f:option value="1" selected="${instance.buildDurationType==1}">${%Average duration}</f:option>
<f:option value="2" selected="${instance.buildDurationType==2}">${%Average duration in minutes-compact}</f:option>
</select>
</div>
</f:entry>
</f:block>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:block>
<p>${%This column shows either all build parameters or build parameters matching a regular expression of the current/last build.}</p>
<div><p>${%This column shows either all build parameters or build parameters matching a regular expression of the current/last build.}</p></div>
<f:optionalBlock field="useRegex" title="${%Use regular expression}" inline="true">
<f:entry field="regex" title="${%Regular expression}" default="">
<f:textbox />
</f:entry>
</f:optionalBlock>
</f:block>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ THE SOFTWARE.
<td>
<j:if test="${job.hasPermission(job.CONFIGURE)}">
<a href="${jobBaseUrl}${job.shortUrl}configure">
<l:icon class="icon-gear ${subIconSizeClass}" title="${%Configure project}" alt="${%Configure project}"/>
<l:icon src="symbol-settings" class="${subIconSizeClass}" title="${%Configure project}" alt="${%Configure project}"/>
</a>
</j:if>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ THE SOFTWARE.

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout" xmlns:f="/lib/form">
<f:block>
<tr>
<td width="50">
<l:icon class="icon-gear icon-xlg" title="${%Configure project icon}" alt="${%Configure project icon}" />
</td>
<td colspan="2">
<p>${%This column adds a shortcut to the configuration page of a project.}</p>
</td>
</tr>
</f:block>
<l:icon src="symbol-settings" class="icon-xlg" alt="${%Configure project icon}" />
<p>${%This column adds a shortcut to the configuration page of a project.}</p>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core">

<td tooltip="${it.getCronTriggerToolTip(job)}">
${it.getCronTrigger(job)}
<td>
<span tooltip="${it.getCronTriggerToolTip(job)}">${it.getCronTrigger(job)}</span>
</td>

</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,5 @@
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:block>
<table>
<tr>
<td colspan="3">${%This column shows the periodic build trigger for the job in cron format.}</td>
</tr>
</table>
</f:block>
<p>${%This column shows the periodic build trigger for the job in cron format.}</p>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
<j:set var="widthAttribute" value="width: ${it.getColumnWidth()}px;word-wrap: break-word;white-space:normal;"/>
<td>
<j:if test="${it.isDisplayName()}">
<a href="${jobBaseUrl}${job.shortUrl}" class='model-link inside'>${relativeDisplayName != null ? relativeDisplayName : job.displayName}</a><br/>
<a href="${jobBaseUrl}${job.shortUrl}" class='jenkins-table__link model-link inside'>${relativeDisplayName != null ? relativeDisplayName : job.displayName}</a><br/>
</j:if>
<div tooltip="${app.markupFormatter.translate(tooltipdesc)}" style="${it.isForceWidth() ? widthAttribute : null}">
<j:out value="${app.markupFormatter.translate(desc)}"/>
<div style="${it.isForceWidth() ? widthAttribute : null}">
<span tooltip="${app.markupFormatter.translate(tooltipdesc)}"><j:out value="${app.markupFormatter.translate(desc)}"/></span>
</div>
</td>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,18 @@
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:block>
<table>
<tr>
<td colspan="3">${%This column shows the project description.}</td>
</tr>
<tr>
<td colspan="3">
<f:checkbox field="displayName" title="${%DescriptionColumn.DisplayName}" />
</td>
</tr>
<f:optionalBlock field="trim" title="${%DescriptionColumn.Trim}" inline="true">
<f:entry title="${%DescriptionColumn.DisplayLength}">
<f:textbox field="displayLength" default="1" />
</f:entry>
</f:optionalBlock>
<f:optionalBlock field="forceWidth" title="${%Force column width}" inline="true">
<f:entry title="${%Column width}">
<f:textbox field="columnWidth" default="80" />
</f:entry>
</f:optionalBlock>
</table>
</f:block>
<div><p>${%This column shows the project description.}</p></div>
<f:entry>
<f:checkbox field="displayName" title="${%DescriptionColumn.DisplayName}" />
</f:entry>
<f:optionalBlock field="trim" title="${%DescriptionColumn.Trim}" inline="true">
<f:entry title="${%DescriptionColumn.DisplayLength}">
<f:textbox field="displayLength" default="1" />
</f:entry>
</f:optionalBlock>
<f:optionalBlock field="forceWidth" title="${%Force column width}" inline="true">
<f:entry title="${%Column width}">
<f:textbox field="columnWidth" default="80" />
</f:entry>
</f:optionalBlock>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,8 @@ THE SOFTWARE.

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<f:block>
<tr>
<td colspan="2">
<p>${%This column adds a button or an icon for disabling/enabling a project.}</p>
<table>
<f:entry>
<f:radio name="useIcon" checked="${instance.useIcon()}" title="${%Use icon}" value="true"/>
</f:entry>
<f:entry>
<f:radio name="useIcon" checked="${!instance.useIcon()}" title="${%Use button}" value="false"/>
</f:entry>
</table>
</td>
</tr>
</f:block>
<f:entry title="${%This column adds a button or an icon for disabling/enabling a project.}">
<f:radio name="useIcon" checked="${instance.useIcon()}" title="${%Use icon}" value="true"/>
<f:radio name="useIcon" checked="${!instance.useIcon()}" title="${%Use button}" value="false"/>
</f:entry>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,7 @@ THE SOFTWARE.

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<f:block>
<tr>
<td width="50">

</td>
<td colspan="2">
<p>${%This column shows the type of the job, eg. Free-style, Maven, Multi-config, Pipeline.}</p>
<f:entry>
<f:checkbox field="usePronoun" title="${%Use pronoun}" />
</f:entry>
</td>
</tr>
</f:block>
<f:entry title="${%This column shows the type of the job, eg. Free-style, Maven, Multi-config, Pipeline.}">
<f:checkbox field="usePronoun" title="${%Use pronoun}" />
</f:entry>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ THE SOFTWARE.
</j:choose>
<j:choose>
<j:when test="${it.showLink and lastBuild != null}">
<td data="${sortData}" tooltip="${tooltip}">${lastBuildString} - <a href="${jobBaseUrl}${job.shortUrl}${it.buildTypeUrl}/" class="model-link inside">${lastBuild.displayName}</a></td>
<td data="${sortData}"><span tooltip="${tooltip}">${lastBuildString}</span> <a href="${jobBaseUrl}${job.shortUrl}${it.buildTypeUrl}/" class="jenkins-table__link jenkins-table__badge model-link inside">${lastBuild.displayName}</a></td>
</j:when>
<j:otherwise>
<td data="${sortData}" tooltip="${tooltip}">${lastBuildString}</td>
<td data="${sortData}"><span tooltip="${tooltip}">${lastBuildString}</span></td>
</j:otherwise>
</j:choose>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,33 @@ THE SOFTWARE.

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<f:block>
<p>${%This column shows the last build.}</p>
<f:entry title="${%Build Start/End}">
<select name="sortType" class="setting-input">
<f:option value="0" selected="${instance.sortType==0}">${%Build start}</f:option>
<f:option value="1" selected="${instance.sortType==1}">${%Build end}</f:option>
</select>
</f:entry>
<f:entry title="${%Build Selector}">
<select name="buildType" class="setting-input">
<f:option value="0" selected="${instance.buildType==0}">${%Last build}</f:option>
<f:option value="1" selected="${instance.buildType==1}">${%Last completed build}</f:option>
<f:option value="2" selected="${instance.buildType==2}">${%Last failed build}</f:option>
<f:option value="3" selected="${instance.buildType==3}">${%Last successful build}</f:option>
<f:option value="4" selected="${instance.buildType==4}">${%Last unsuccessful build}</f:option>
<f:option value="5" selected="${instance.buildType==5}">${%Last stable build}</f:option>
<f:option value="6" selected="${instance.buildType==6}">${%Last unstable build}</f:option>
</select>
</f:entry>
<f:entry title="${%Show relative times}">
<f:checkbox field="useRelative" />
</f:entry>
<f:entry title="${%Show link to build}">
<f:checkbox field="showLink" />
</f:entry>
</f:block>

<div><p>${%This column shows the last build.}</p></div>
<f:entry title="${%Build Start/End}">
<div class="jenkins-select">
<select name="sortType" class="jenkins-select__input">
<f:option value="0" selected="${instance.sortType==0}">${%Build start}</f:option>
<f:option value="1" selected="${instance.sortType==1}">${%Build end}</f:option>
</select>
</div>
</f:entry>
<f:entry title="${%Build Selector}">
<div class="jenkins-select">
<select name="buildType" class="jenkins-select__input">
<f:option value="0" selected="${instance.buildType==0}">${%Last build}</f:option>
<f:option value="1" selected="${instance.buildType==1}">${%Last completed build}</f:option>
<f:option value="2" selected="${instance.buildType==2}">${%Last failed build}</f:option>
<f:option value="3" selected="${instance.buildType==3}">${%Last successful build}</f:option>
<f:option value="4" selected="${instance.buildType==4}">${%Last unsuccessful build}</f:option>
<f:option value="5" selected="${instance.buildType==5}">${%Last stable build}</f:option>
<f:option value="6" selected="${instance.buildType==6}">${%Last unstable build}</f:option>
</select>
</div>
</f:entry>
<f:entry title="${%Show relative times}">
<f:checkbox field="useRelative" />
</f:entry>
<f:entry title="${%Show link to build}">
<f:checkbox field="showLink" />
</f:entry>
</j:jelly>
Loading
Loading