Skip to content

Commit f22f784

Browse files
Hugo SarbiaRoemer
authored andcommitted
Support swarm agent provisioning when label is dynamically assigned with groovy script
1 parent 2e312b9 commit f22f784

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

src/main/java/org/jenkinsci/plugins/docker/swarm/DockerSwarmAgent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public class DockerSwarmAgent extends AbstractCloudSlave implements EphemeralNod
2828
public DockerSwarmAgent(final Queue.BuildableItem bi, final String labelString)
2929
throws Descriptor.FormException, IOException {
3030
super(labelString, "Docker swarm agent for building " + bi.task.getFullDisplayName(),
31-
DockerSwarmCloud.get().getLabelConfiguration(bi.task.getAssignedLabel().getName()).getWorkingDir(), 1,
32-
Mode.EXCLUSIVE, labelString, new DockerSwarmComputerLauncher(bi),
31+
DockerSwarmCloud.get().getLabelConfiguration(bi.getAssignedLabel().getName()).getWorkingDir(), 1,
32+
Mode.EXCLUSIVE, bi.getAssignedLabel().getName(), new DockerSwarmComputerLauncher(bi),
3333
new DockerSwarmAgentRetentionStrategy(1), Collections.emptyList());
3434
LOGGER.log(Level.FINE, "Created docker swarm agent: {0}", labelString);
3535
}

src/main/java/org/jenkinsci/plugins/docker/swarm/DockerSwarmComputerLauncher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class DockerSwarmComputerLauncher extends JNLPLauncher {
4747
public DockerSwarmComputerLauncher(final Queue.BuildableItem bi) {
4848
super(DockerSwarmCloud.get().getTunnel(), null, new RemotingWorkDirSettings(false, "/tmp", null, false));
4949
this.bi = bi;
50-
this.label = bi.task.getAssignedLabel().getName();
50+
this.label = bi.getAssignedLabel().getName();
5151
this.jobName = bi.task instanceof AbstractProject ? ((AbstractProject) bi.task).getFullName()
5252
: bi.task.getName();
5353
}

src/main/java/org/jenkinsci/plugins/docker/swarm/OneShotProvisionQueueListener.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ public class OneShotProvisionQueueListener extends QueueListener {
1919

2020
@Override
2121
public void onEnterBuildable(final Queue.BuildableItem bi) {
22-
final Queue.Task job = bi.task;
2322
if (DockerSwarmCloud.get() != null) {
2423
final List<String> labels = DockerSwarmCloud.get().getLabels();
25-
if (job.getAssignedLabel() != null && labels.contains(job.getAssignedLabel().getName())) {
24+
if (bi.getAssignedLabel() != null && labels.contains(bi.getAssignedLabel().getName())) {
2625
BuildScheduler.scheduleBuild(bi);
2726
}
2827
}

src/main/java/org/jenkinsci/plugins/docker/swarm/dashboard/SwarmQueueItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class SwarmQueueItem {
2020

2121
public SwarmQueueItem(final Queue.BuildableItem item) {
2222
this.name = item.task.getFullDisplayName();
23-
this.label = item.task.getAssignedLabel().getName();
23+
this.label = item.getAssignedLabel().getName();
2424
this.labelConfig = DockerSwarmCloud.get().getLabelConfiguration(this.label);
2525
this.inQueueSince = item.getInQueueForString();
2626
this.agentInfo = item.getAction(DockerSwarmAgentInfo.class); // this should never be null

0 commit comments

Comments
 (0)