Skip to content

Commit 69eaf86

Browse files
committed
Added getQueue()
1 parent 80fd834 commit 69eaf86

3 files changed

Lines changed: 80 additions & 1 deletion

File tree

src/main/java/com/offbytwo/jenkins/JenkinsServer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.google.common.base.Function;
2222
import com.google.common.base.Optional;
2323
import com.google.common.collect.ImmutableMap;
24+
import com.google.common.collect.Lists;
2425
import com.google.common.collect.Maps;
2526
import com.offbytwo.jenkins.client.JenkinsHttpClient;
2627
import com.offbytwo.jenkins.client.util.EncodingUtils;
@@ -35,6 +36,7 @@
3536
import com.offbytwo.jenkins.model.MainView;
3637
import com.offbytwo.jenkins.model.MavenJobWithDetails;
3738
import com.offbytwo.jenkins.model.PluginManager;
39+
import com.offbytwo.jenkins.model.Queue;
3840
import com.offbytwo.jenkins.model.QueueItem;
3941
import com.offbytwo.jenkins.model.QueueReference;
4042
import com.offbytwo.jenkins.model.View;
@@ -572,6 +574,10 @@ public String runScript(String script) throws IOException {
572574
return client.post_text("/scriptText", "script=" + script, ContentType.APPLICATION_FORM_URLENCODED, false);
573575
}
574576

577+
public Queue getQueue() throws IOException {
578+
return client.get("queue/?depth=1", Queue.class);
579+
}
580+
575581
public QueueItem getQueueItem(QueueReference ref) throws IOException {
576582
try {
577583
String url = ref.getQueueItemUrlPart();
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package com.offbytwo.jenkins.model;
2+
3+
import java.util.List;
4+
5+
public class Queue
6+
extends BaseModel
7+
{
8+
private List<String> discoverableItems;
9+
10+
private List<QueueItem> items;
11+
12+
public Queue()
13+
{
14+
}
15+
16+
public List<String> getDiscoverableItems()
17+
{
18+
return discoverableItems;
19+
}
20+
21+
public void setDiscoverableItems( List<String> discoverableItems )
22+
{
23+
this.discoverableItems = discoverableItems;
24+
}
25+
26+
@Override
27+
public int hashCode()
28+
{
29+
final int prime = 31;
30+
int result = 1;
31+
result = prime * result + ( ( discoverableItems == null ) ? 0 : discoverableItems.hashCode() );
32+
result = prime * result + ( ( items == null ) ? 0 : items.hashCode() );
33+
return result;
34+
}
35+
36+
public List<QueueItem> getItems()
37+
{
38+
return items;
39+
}
40+
41+
public void setItems( List<QueueItem> items )
42+
{
43+
this.items = items;
44+
}
45+
46+
@Override
47+
public boolean equals( Object obj )
48+
{
49+
if ( this == obj )
50+
return true;
51+
if ( obj == null )
52+
return false;
53+
if ( getClass() != obj.getClass() )
54+
return false;
55+
Queue other = (Queue) obj;
56+
if ( discoverableItems == null )
57+
{
58+
if ( other.discoverableItems != null )
59+
return false;
60+
}
61+
else if ( !discoverableItems.equals( other.discoverableItems ) )
62+
return false;
63+
if ( items == null )
64+
{
65+
if ( other.items != null )
66+
return false;
67+
}
68+
else if ( !items.equals( other.items ) )
69+
return false;
70+
return true;
71+
}
72+
73+
}

src/main/java/com/offbytwo/jenkins/model/QueueItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class QueueItem extends BaseModel {
1818
// task
1919

2020
private String url;
21-
21+
2222
private String why;
2323

2424
private boolean cancelled;

0 commit comments

Comments
 (0)