/**
   * Note that with Hudson 1.341, trigger should be using {@link
   * BuildTrigger#buildDependencyGraph(AbstractProject, hudson.model.DependencyGraph)}.
   */
  public List<Future<AbstractBuild>> perform(
      AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
      throws InterruptedException, IOException {
    EnvVars env = build.getEnvironment(listener);
    env.overrideAll(build.getBuildVariables());

    try {
      if (condition.isMet(build.getResult())) {
        List<Action> actions = getBaseActions(build, listener);

        List<Future<AbstractBuild>> futures = new ArrayList<Future<AbstractBuild>>();
        for (AbstractProject project : getProjectList(env)) {
          List<Action> list = getBuildActions(actions, project);

          futures.add(schedule(build, project, list));
        }
        return futures;
      }
    } catch (DontTriggerException e) {
      // don't trigger on this configuration
    }
    return Collections.emptyList();
  }
Exemplo n.º 2
0
  /**
   * @deprecated since 2.3 with Hudson 1.341+ (see {@link
   *     BuildTrigger#buildDependencyGraph(AbstractProject, hudson.model.DependencyGraph)})
   */
  @Deprecated
  public void perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
      throws InterruptedException, IOException {

    try {
      if (condition.isMet(build.getResult())) {
        List<Action> actions = getBaseActions(build, listener);
        if (!actions.isEmpty()) {
          for (AbstractProject project : getProjectList()) {
            List<Action> list = getBuildActions(actions, project);

            project.scheduleBuild(
                project.getQuietPeriod(),
                new Cause.UpstreamCause((Run) build),
                list.toArray(new Action[list.size()]));
          }
        }
      }
    } catch (DontTriggerException e) {
      // don't trigger on this configuration
      return;
    }
  }