提交 23d800cf 编写于 作者: D Daniel Beck

Merge pull request #1617 from KostyaSha/cronFix

Don't run trigger for disabled/copied projects
......@@ -324,6 +324,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
buildMixIn.onLoad(parent, name);
builds = buildMixIn.getRunMap();
triggers().setOwner(this);
if (isBuildable()) {
for (Trigger t : triggers()) {
try {
t.start(this, Items.currentlyUpdatingByXml());
......@@ -331,6 +332,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
LOGGER.log(Level.WARNING, "could not start trigger while loading project '" + getFullName() + "'", e);
}
}
}
if(scm==null)
scm = new NullSCM(); // perhaps it was pointing to a plugin that no longer exists.
......@@ -1879,8 +1881,10 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
for (Trigger t : triggers())
t.stop();
triggers.replaceBy(buildDescribable(req, Trigger.for_(this)));
if (isBuildable()) {
for (Trigger t : triggers())
t.start(this,true);
t.start(this, true);
}
}
/**
......
......@@ -99,6 +99,8 @@ public abstract class Trigger<J extends Item> implements Describable<Trigger<?>>
*
* This method is invoked when {@link #Trigger(String)} is used
* to create an instance, and the crontab matches the current time.
* <p>
* Maybe run even before {@link #start(hudson.model.Item, boolean)}, prepare for it.
*/
public void run() {}
......@@ -241,6 +243,10 @@ public abstract class Trigger<J extends Item> implements Describable<Trigger<?>>
// FIXME allow to set a global crontab spec
previousSynchronousPolling = scmd.getExecutor().submit(new DependencyRunner(new ProjectRunnable() {
public void run(AbstractProject p) {
if (!p.isBuildable()) {
return; //skip disabled/copied project
}
for (Trigger t : (Collection<Trigger>) p.getTriggers().values()) {
if (t instanceof SCMTrigger) {
LOGGER.fine("synchronously triggering SCMTrigger for project " + t.job.getName());
......@@ -256,6 +262,12 @@ public abstract class Trigger<J extends Item> implements Describable<Trigger<?>>
// Process all triggers, except SCMTriggers when synchronousPolling is set
for (ParameterizedJobMixIn.ParameterizedJob p : inst.getAllItems(ParameterizedJobMixIn.ParameterizedJob.class)) {
if (p instanceof AbstractProject<?, ?>) {
if (!((AbstractProject) p).isBuildable()) {
continue; // skip disabled/copied project
}
}
for (Trigger t : p.getTriggers().values()) {
if (! (t instanceof SCMTrigger && scmd.synchronousPolling)) {
LOGGER.log(Level.FINE, "cron checking {0} with spec ‘{1}’", new Object[] {p, t.spec.trim()});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册