Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package hudson.plugins.downstream_ext;
  
  import hudson.model.Cause;
  import hudson.model.Run;
 
 import java.util.List;
Defines a dependency introduced by the downstream-ext plugin.

Author(s):
kutzi
 
 public class DownstreamDependency extends Dependency {
 
 	private static final Logger LOGGER = Logger.getLogger(DownstreamDependency.class.getName());
 	
 	private final DownstreamTrigger trigger;
 
 	public DownstreamDependency(AbstractProject<?, ?> upstreamAbstractProject<?, ?> downstream,
 			DownstreamTrigger trigger) {
 		super(upstreamdownstream);
 		this. = trigger;
 	}

 
 	@SuppressWarnings("unchecked")
 	public boolean shouldTriggerBuild(AbstractBuild build,
 			TaskListener listenerList<Actionactions) {
 		PrintStream logger = listener.getLogger();
             AbstractProject p = getDownstreamProject();
                 
             if(.isOnlyIfSCMChanges()) {
             	if (p.getScm().requiresWorkspaceForPolling()) {
             		// Downstream project locks workspace while building.
             		// If polled synchronously this could make the upstream build
             		// lock for a possibly long time.
             		// See HUDSON-5406
             		logger.println(Messages.DownstreamTrigger_StartedAsynchPoll(p.getName()));
             		Thread t = new Thread(new PollRunner(pnew Cause.UpstreamCause((Run<?,?>)build)));
             		t.start();
             		return false;
             	}
             	
             	if (p.pollSCMChanges(listener)) {
             		return true;
             	} else {
             		logger.println(Messages.DownstreamTrigger_NoSCMChanges(p.getName()));
             		return false;
             	}
             }
             return true;
 		} else {
 			return false;
 		}
 	}
 
 	// Technically it'd be safe to not override equals
 	// since superclass implements it well.
 	// But maybe that changes in the future.
 	public boolean equals(Object obj) {
 		if (!(obj instanceof DownstreamDependency)) {
 			return false;
 		}
 		
 		// Currently, there can be only one downstream-ext dependency per project
 		// If that'd change later we must check the trigger instance here, too.
 		
 		return super.equals(obj);
 	}
 	
 	@SuppressWarnings("unchecked")
 	private static class PollRunner implements Runnable {
 
 		private final AbstractProject project;
 		private final Cause cause;
 		private final TaskListener taskListener;
 
 		public PollRunner(AbstractProject pCause cause) {
 			this. = p;
 			this. = cause;
 		}
 		
		public void run() {
			}
		}
	}
New to GrepCode? Check out our FAQ X