Skip to content
Permalink
Browse files

New functionality allowing one project's trigger to depend on others'.

This feature adds a Project Dependency system to the gerrit trigger
plugin. In the advanced section of the trigger, it is possible to add
projects as "dependencies" (a check for cycles is performed at that time
to prevent depending on something which depends on self).
There is an auto-complete functionality.
If such a dependency project is added, then when a gerrit event happens
which should trigger both the project and its upstream dependency, the
new QueueTaskDispatcher will wait for the upstream to finish before
building the downstream project.

Known limitation: in "normal" situations, the dispatcher must assume
that all projects are triggered before any build is considered in the
queue by Jenkins to check if it canRun(). This is usually the case
because of a "quiet" period of 3 seconds allowing triggering to
complete, even for a large number of projects, before queue is
processed.
For the RetriggerAll action and ManualPatchsetCreated, this limitation
is not present as there are hooks allowing to guarantee that all
projects are triggered before consideration of the queue.
  • Loading branch information...
yannack committed Mar 5, 2014
1 parent a0c4474 commit 08fb5a2be7036934a37af1b39c5ca535c5f37850
@@ -0,0 +1,54 @@
/*
* The MIT License
*
* Copyright 2014 Smartmatic International Corporation. All rights reserved.
*
* 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 com.sonyericsson.hudson.plugins.gerrit.trigger.dependency;

import hudson.model.AbstractProject;
import hudson.model.queue.CauseOfBlockage;

import java.util.List;

import com.google.common.base.Joiner;
import com.sonyericsson.hudson.plugins.gerrit.trigger.Messages;

/**
* Build is blocked because it depends on a currently building job.
* @author Yannick Bréhon <yannick.brehon@smartmatic.com>
*/
public class BecauseDependentBuildIsBuilding extends CauseOfBlockage {

private List<AbstractProject> blockingProjects;

/**
* Standard constructor.
* @param blockingProjects The list of dependant builds which are blocking this one.
*/
public BecauseDependentBuildIsBuilding(List<AbstractProject> blockingProjects) {
this.blockingProjects = blockingProjects;
}

@Override
public String getShortDescription() {
return Messages.DependentBuildIsBuilding(Joiner.on(", ").join(blockingProjects));
}
}
@@ -0,0 +1,44 @@
/*
* The MIT License
*
* Copyright 2014 Smartmatic International Corporation. All rights reserved.
*
* 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 com.sonyericsson.hudson.plugins.gerrit.trigger.dependency;
import hudson.model.queue.CauseOfBlockage;
import com.sonyericsson.hudson.plugins.gerrit.trigger.Messages;

/**
* Build is blocked because it depends on a currently building job.
* @author Yannick Bréhon &lt;yannick.brehon@smartmatic.com&gt;
*/
public class BecauseWaitingForOtherProjectsToTrigger extends CauseOfBlockage {

/**
* Standard constructor.
*/
public BecauseWaitingForOtherProjectsToTrigger() {
}

@Override
public String getShortDescription() {
return Messages.WaitingForDependencyProjectsToTrigger();
}
}

0 comments on commit 08fb5a2

Please sign in to comment.
You can’t perform that action at this time.