forked from geoffbullen/build-pipeline-plugin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JENKINS-38670 refactor build card to a BuildCardExtension class
Move all "Build Card" display and trigger logic into a BuildCardExtension class. This allows plugins or other BuildCardExtension children to customize behavior, for example to require approval notes
- Loading branch information
Dan Alvizu
committed
Dec 1, 2016
1 parent
62192c7
commit 8ef34e2
Showing
15 changed files
with
694 additions
and
425 deletions.
There are no files selected for viewing
304 changes: 39 additions & 265 deletions
304
src/main/java/au/com/centrumsystems/hudson/plugin/buildpipeline/BuildPipelineView.java
Large diffs are not rendered by default.
Oops, something went wrong.
353 changes: 353 additions & 0 deletions
353
.../java/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/BuildCardExtension.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
64 changes: 64 additions & 0 deletions
64
...n/java/au/com/centrumsystems/hudson/plugin/buildpipeline/extension/StandardBuildCard.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,64 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2016 the Jenkins project | ||
* | ||
* 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 au.com.centrumsystems.hudson.plugin.buildpipeline.extension; | ||
|
||
import hudson.Extension; | ||
import hudson.model.Descriptor; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
|
||
/** | ||
* @author dalvizu | ||
*/ | ||
@Extension | ||
public class StandardBuildCard | ||
extends BuildCardExtension { | ||
|
||
/** | ||
* Default constructor | ||
*/ | ||
@DataBoundConstructor | ||
public StandardBuildCard() { | ||
|
||
} | ||
|
||
@Override | ||
public long getIndex() { | ||
return 0; | ||
} | ||
|
||
/** | ||
* Descriptor, since we're in the UI | ||
*/ | ||
@Extension | ||
public static class DescriptorImpl | ||
extends Descriptor<BuildCardExtension> { | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return "Standard build card"; | ||
} | ||
} | ||
} |
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
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
143 changes: 143 additions & 0 deletions
143
...msystems/hudson/plugin/buildpipeline/extension/BuildCardExtension/buildCardTemplate.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,143 @@ | ||
<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"> | ||
<div class="build-card rounded {{build.status}} {{#if project.disabled}}disabled{{/if}}"> | ||
<div class="header"> | ||
<a href="${rootURL}/{{build.url}}" title="{{project.name}}"> | ||
{{#unless build.isPending}} | ||
{{#unless build.isReadyToBeManuallyBuilt}} | ||
{{#if build.displayName}} | ||
{{build.displayName}} | ||
{{else}} | ||
#{{build.number}} | ||
{{/if}} | ||
{{/unless}} | ||
{{/unless}} | ||
{{#if project.displayName}} | ||
{{project.displayName}} | ||
{{else}} | ||
{{project.name}} | ||
{{/if}} | ||
</a> | ||
</div> | ||
<div class="build-info"> | ||
<ul> | ||
{{#if build.startDate}} | ||
<li class="build-time" title="Start date: {{build.startDate}} {{build.startTime}}">{{build.startDate}} {{build.startTime}}</li> | ||
{{else}} | ||
<li class="build-time"><abbr title="Not Applicable">N/A</abbr></li> | ||
{{/if}} | ||
|
||
{{#if build.isBuilding}} | ||
<li class="build-duration" title="Build duration: {{build.duration}}">{{build.duration}}</li> | ||
{{else}} | ||
{{#if build.isComplete}} | ||
<li class="build-duration" title="Build duration: {{build.duration}}">{{build.duration}}</li> | ||
{{else}} | ||
<li class="build-duration"><abbr title="Not Applicable">N/A</abbr></li> | ||
{{/if}} | ||
{{/if}} | ||
|
||
{{#if build.userId}} | ||
<li class="build-user" title="User: {{build.userId}}">{{build.userId}}</li> | ||
{{/if}} | ||
</ul> | ||
</div> | ||
<div class="build-actions"> | ||
{{#unless project.disabled}} | ||
<div class="status-bar" id="status-bar-{{id}}"> | ||
{{#if build.isBuilding}} | ||
<div onclick="buildPipeline.fillDialog('${app.rootUrl}{{build.url}}console', 'Console output for {{project.name}} #{{build.number}}')"> | ||
<table class="progress-bar" align="center"> | ||
<tbody> | ||
<tr title="Estimated remaining time: {{build.estimatedRemainingTime}}"> | ||
<td style="width: {{build.progress}}%" class="progress-bar-done" id="progress-bar-done{{id}}"></td> | ||
<td style="width: {{build.progressLeft}}%" class="progress-bar-left" id="progress-bar-left{{id}}"></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
{{/if}} | ||
</div> | ||
|
||
<div class="icons" id="icons-{{id}}"> | ||
{{#if project.parameters.length}} | ||
<j:set var="hasParameterIconUrl" value="${rootURL}/plugin/build-pipeline-plugin/images/has-parameter.png" /> | ||
<img title="This job has parameters" alt="This job has parameters" src="${hasParameterIconUrl}"/> | ||
{{/if}} | ||
{{#unless build.isPending}} | ||
{{#unless build.isReadyToBeManuallyBuilt}} | ||
<j:set var="consoleOutputIconUrl" value="${rootURL}/images/16x16/terminal.png" /> | ||
<j:choose> | ||
<j:when test="${from.newWindowConsoleOutputLinkStyle}"> | ||
<a href="${rootURL}/{{build.url}}console" target="_blank"> | ||
<img title="console" alt="console" src="${consoleOutputIconUrl}" /> | ||
</a> | ||
</j:when> | ||
<j:when test="${from.thisWindowConsoleOutputLinkStyle}"> | ||
<a href="${rootURL}/{{build.url}}console"> | ||
<img title="console" alt="console" src="${consoleOutputIconUrl}" /> | ||
</a> | ||
</j:when> | ||
<j:otherwise> | ||
<span onclick="buildPipeline.fillDialog('${app.rootUrl}{{build.url}}console', 'Console output for {{project.name}} #{{build.number}}')"> | ||
<img title="console" alt="console" src="${consoleOutputIconUrl}" /> | ||
</span> | ||
</j:otherwise> | ||
</j:choose> | ||
{{/unless}} | ||
{{/unless}} | ||
|
||
{{#if build.isRerunnable}} | ||
{{#if build.isSuccess}} | ||
{{#if ${!from.triggerOnlyLatestJob}}} | ||
<j:if test="${from.hasBuildPermission()}"> | ||
<span onclick="buildPipeline.showSpinner({{id}}); buildPipeline.rerunBuild({{id}}, '{{build.extId}}', [{{build.dependencyIds}}])"> | ||
<img title="re-run" alt="re-run" src="${rootURL}/images/16x16/redo.png" /> | ||
</span> | ||
</j:if> | ||
{{/if}} | ||
{{else}} | ||
{{#if ${from.triggerOnlyLatestJob}}} | ||
{{#if build.isLatestBuild}} | ||
{{#if build.isUpstreamBuildLatest}} | ||
<span onclick="buildPipeline.showSpinner({{id}}); buildPipeline.rerunBuild({{id}}, '{{build.extId}}', [{{build.dependencyIds}}])"> | ||
<img title="retry" alt="retry" src="${rootURL}/images/16x16/redo.png" /> | ||
</span> | ||
{{/if}} | ||
{{/if}} | ||
{{else}} | ||
{{#if build.isManual}} | ||
<span onclick="buildPipeline.showSpinner({{id}}); buildPipeline.triggerBuild({{id}}, '{{upstream.projectName}}', {{upstream.buildNumber}}, '{{project.name}}', [{{build.dependencyIds}}])"> | ||
<img title="retry" alt="retry" src="${rootURL}/images/16x16/clock.png" /> | ||
</span> | ||
{{else}} | ||
<span onclick="buildPipeline.showSpinner({{id}}); buildPipeline.rerunBuild({{id}}, '{{build.extId}}', [{{build.dependencyIds}}])"> | ||
<img title="retry" alt="retry" src="${rootURL}/images/16x16/redo.png" /> | ||
</span> | ||
{{/if}} | ||
{{/if}} | ||
{{/if}} | ||
{{/if}} | ||
|
||
{{#if build.isReadyToBeManuallyBuilt}} | ||
{{#if ${from.triggerOnlyLatestJob}}} | ||
{{#if build.isUpstreamBuildLatestSuccess}} | ||
<span onclick="buildPipeline.showSpinner({{id}}); buildPipeline.triggerBuild({{id}}, '{{upstream.projectName}}', {{upstream.buildNumber}}, '{{project.name}}', [{{build.dependencyIds}}])"> | ||
<img title="trigger" alt="trigger" src="${rootURL}/images/16x16/clock.png" /> | ||
</span> | ||
{{/if}} | ||
{{else}} | ||
<span onclick="buildPipeline.showSpinner({{id}}); buildPipeline.triggerBuild({{id}}, '{{upstream.projectName}}', {{upstream.buildNumber}}, '{{project.name}}', [{{build.dependencyIds}}])"> | ||
<img title="trigger" alt="trigger" src="${rootURL}/images/16x16/clock.png" /> | ||
</span> | ||
{{/if}} | ||
{{/if}} | ||
</div> | ||
{{/unless}} | ||
{{#if project.disabled}} | ||
<div class="icons" id="icons-{{id}}"> | ||
<span class="disabled"><img src="${rootURL}/images/16x16/warning.png" atl="disabled" title="disabled" /></span> | ||
</div> | ||
{{/if}} | ||
</div> | ||
</div> | ||
</j:jelly> |
13 changes: 13 additions & 0 deletions
13
...u/com/centrumsystems/hudson/plugin/buildpipeline/extension/StandardBuildCard/config.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,13 @@ | ||
<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"> | ||
|
||
<f:description> | ||
Use the default build cards | ||
</f:description> | ||
|
||
</j:jelly> | ||
|
Oops, something went wrong.