Navigation Menu

Skip to content

Commit

Permalink
[FIXED JENKINS-14813] 404 canceling queue items.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Aug 15, 2012
1 parent c2f3012 commit 43f1f5d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
5 changes: 4 additions & 1 deletion changelog.html
Expand Up @@ -55,9 +55,12 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=bug>
Avoid a 404 when canceling queue items.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-14813">issue 14813</a>)
<li class=bug>
Added missing parameters as defaults when called from CLI
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-7162">issue 7162</a>)
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-7162">issue 7162</a>)
<li class=bug>
NPE from <code>UpdateSite$Plugin.getNeededDependencies</code>.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-14769">issue 14769</a>)
Expand Down
17 changes: 14 additions & 3 deletions core/src/main/java/hudson/model/Queue.java
Expand Up @@ -102,6 +102,7 @@

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter;
import org.kohsuke.stapler.QueryParameter;

/**
* Build queue.
Expand Down Expand Up @@ -570,6 +571,17 @@ public synchronized boolean cancel(Item item) {
return r;
}

/**
* Called from {@code queue.jelly} and {@code entries.jelly}.
*/
public HttpResponse doCancelItem(@QueryParameter int id) throws IOException, ServletException {
Item item = getItem(id);
if (item != null) {
cancel(item);
} // else too late, ignore (JENKINS-14813)
return HttpResponses.forwardToPreviousPage();
}

public synchronized boolean isEmpty() {
return waitingList.isEmpty() && blockedProjects.isEmpty() && buildables.isEmpty() && pendings.isEmpty();
}
Expand Down Expand Up @@ -1362,9 +1374,8 @@ public String getSearchUrl() {
return null;
}

/**
* Called from queue.jelly.
*/
/** @deprecated Use {@link #doCancelItem} instead. */
@Deprecated
public HttpResponse doCancelQueue() throws IOException, ServletException {
Jenkins.getInstance().getQueue().cancel(this);
return HttpResponses.forwardToPreviousPage();
Expand Down
Expand Up @@ -43,7 +43,7 @@ THE SOFTWARE.
<td style="white-space:normal;" colspan="2">
<div style="float:right">
<j:if test="${item.hasCancelPermission()}">
<a href="${rootURL}/queue/item/${item.id}/cancelQueue">
<a href="${rootURL}/queue/cancelItem?id=${item.id}">
<img src="${imagesURL}/16x16/stop.png" alt="${%cancel this build}" height="16" width="16"/>
</a>
</j:if>
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/lib/hudson/queue.jelly
Expand Up @@ -79,7 +79,7 @@ THE SOFTWARE.
</td>
<td class="pane" width="16" align="center" valign="middle">
<j:if test="${item.hasCancelPermission()}">
<a href="${rootURL}/queue/item/${item.id}/cancelQueue"><img src="${imagesURL}/16x16/stop.png" alt="cancel this build" height="16" width="16"/></a>
<a href="${rootURL}/queue/cancelItem?id=${item.id}"><img src="${imagesURL}/16x16/stop.png" alt="cancel this build" height="16" width="16"/></a>
</j:if>
</td>
</tr>
Expand Down

0 comments on commit 43f1f5d

Please sign in to comment.