Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from amuniz/pr-26-fix
[JENKINS-34268][JENKINS-34273] Lock multiple resources with specific quantity
- Loading branch information
Showing
14 changed files
with
640 additions
and
124 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/main/java/org/jenkins/plugins/lockableresources/BackwardCompatibility.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,47 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Copyright (c) 2016, Florian Hug. All rights reserved. * | ||
* * | ||
* This file is part of the Jenkins Lockable Resources Plugin and is * | ||
* published under the MIT license. * | ||
* * | ||
* See the "LICENSE.txt" file for more information. * | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
|
||
package org.jenkins.plugins.lockableresources; | ||
|
||
import hudson.init.InitMilestone; | ||
import hudson.init.Initializer; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.jenkinsci.plugins.workflow.steps.StepContext; | ||
import org.jenkins.plugins.lockableresources.queue.LockableResourcesStruct; | ||
import org.jenkins.plugins.lockableresources.queue.QueuedContextStruct; | ||
import org.jenkins.plugins.lockableresources.LockableResource; | ||
import org.jenkins.plugins.lockableresources.LockableResourcesManager; | ||
|
||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public final class BackwardCompatibility { | ||
private static final Logger LOG = Logger.getLogger(BackwardCompatibility.class.getName()); | ||
|
||
@Initializer(after = InitMilestone.JOB_LOADED) | ||
public static void compatibilityMigration() { | ||
LOG.log(Level.FINE, "lockable-resource-plugin compatibility migration task run"); | ||
List<LockableResource> resources = LockableResourcesManager.get().getResources(); | ||
for (LockableResource resource : resources) { | ||
List<StepContext> queuedContexts = resource.getQueuedContexts(); | ||
if (queuedContexts.size() > 0) { | ||
for (StepContext queuedContext : queuedContexts) { | ||
List<String> resourcesNames = new ArrayList<String>(); | ||
resourcesNames.add(resource.getName()); | ||
LockableResourcesStruct resourceHolder = new LockableResourcesStruct(resourcesNames, "", 0); | ||
LockableResourcesManager.get().queueContext(queuedContext, resourceHolder, resource.getName()); | ||
} | ||
queuedContexts.clear(); | ||
} | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.