Java 类hudson.model.Cause.UpstreamCause 实例源码

项目:gitlab-plugin    文件:CommitStatusUpdater.java   
private static List<GitLabBranchBuild> findBuildsFromUpstreamCauses(List<Cause> causes) {
    for (Cause cause : causes) {
        if (cause instanceof UpstreamCause) {
            List<Cause> upCauses = ((UpstreamCause) cause).getUpstreamCauses();    // Non null, returns empty list when none are set
            for (Cause upCause : upCauses) {
                if (upCause instanceof GitLabWebHookCause) {
                    GitLabWebHookCause gitlabCause = (GitLabWebHookCause) upCause;
                    return Collections.singletonList(
                            new GitLabBranchBuild(gitlabCause.getData().getSourceProjectId().toString(),
                                    gitlabCause.getData().getLastCommit()));
                }
            }
            List<GitLabBranchBuild> builds = findBuildsFromUpstreamCauses(upCauses);
            if (!builds.isEmpty()) {
                return builds;
            }
        }
    }
    return Collections.emptyList();
}
项目:jira-steps    文件:JiraStepExecution.java   
/**
 * Return the current build user.
 * 
 * @param causes
 *            build causes.
 * @return user name.
 */
protected static String prepareBuildUser(List<Cause> causes) {
    String buildUser = "anonymous";
    if (causes != null && causes.size() > 0) {
        if (causes.get(0) instanceof UserIdCause) {
            buildUser = ((UserIdCause) causes.get(0)).getUserName();
        } else if (causes.get(0) instanceof UpstreamCause) {
            List<Cause> upstreamCauses = ((UpstreamCause) causes.get(0)).getUpstreamCauses();
            prepareBuildUser(upstreamCauses);
        }
    }
    return buildUser;
}
项目:jira-steps-plugin    文件:JiraStepExecution.java   
/**
 * Return the current build user.
 *
 * @param causes build causes.
 * @return user name.
 */
protected static String prepareBuildUser(List<Cause> causes) {
  String buildUser = "anonymous";
  if (causes != null && causes.size() > 0) {
    if (causes.get(0) instanceof UserIdCause) {
      buildUser = ((UserIdCause) causes.get(0)).getUserId();
    } else if (causes.get(0) instanceof UpstreamCause) {
      List<Cause> upstreamCauses = ((UpstreamCause) causes.get(0)).getUpstreamCauses();
      prepareBuildUser(upstreamCauses);
    }
  }
  return Util.fixEmpty(buildUser) == null ? "anonymous" : buildUser;
}
项目:hubot-steps-plugin    文件:HubotAbstractSynchronousNonBlockingStepExecution.java   
/**
 * Return the current build user.
 * 
 * @param causes build causes.
 * @return user name.
 */
protected static String prepareBuildUser(List<Cause> causes) {
  String buildUser = "anonymous";
  if (causes != null && causes.size() > 0) {
    if (causes.get(0) instanceof UserIdCause) {
      buildUser = ((UserIdCause) causes.get(0)).getUserName();
    } else if (causes.get(0) instanceof UpstreamCause) {
      List<Cause> upstreamCauses = ((UpstreamCause) causes.get(0)).getUpstreamCauses();
      prepareBuildUser(upstreamCauses);
    }
  }
  return buildUser;
}
项目:hubot-steps-plugin    文件:HubotStepExecution.java   
/**
 * Return the current build user.
 * 
 * @param causes build causes.
 * @return user name.
 */
protected static String prepareBuildUser(List<Cause> causes) {
  String buildUser = "anonymous";
  if (causes != null && causes.size() > 0) {
    if (causes.get(0) instanceof UserIdCause) {
      buildUser = ((UserIdCause) causes.get(0)).getUserName();
    } else if (causes.get(0) instanceof UpstreamCause) {
      List<Cause> upstreamCauses = ((UpstreamCause) causes.get(0)).getUpstreamCauses();
      prepareBuildUser(upstreamCauses);
    }
  }
  return buildUser;
}
项目:run-selector-plugin    文件:TriggeringRunSelector.java   
@Nonnull
private HashSet<Run<?, ?>> getAllUpstreamBuilds(@Nonnull Job<?, ?> job, @Nonnull RunSelectorContext context, @Nonnull Run<?, ?> parent) {
    HashSet<Run<?, ?>> result = new HashSet<Run<?, ?>>();

    // Upstream job for matrix will be parent project, not only individual configuration:
    List<String> jobNames = new ArrayList<String>();
    jobNames.add(job.getFullName());
    if ((job instanceof AbstractProject<?,?>) && ((AbstractProject<?,?>)job).getRootProject() != job) {
        jobNames.add(((AbstractProject<?,?>)job).getRootProject().getFullName());
    }

    List<Run<?, ?>> upstreamBuilds = new ArrayList<Run<?, ?>>();

    for (Cause cause: parent.getCauses()) {
        if (cause instanceof UpstreamCause) {
            UpstreamCause upstream = (UpstreamCause) cause;
            Run<?, ?> upstreamRun = upstream.getUpstreamRun();
            if (upstreamRun != null) {
                upstreamBuilds.add(upstreamRun);
            }
        }
    }

    if (isAllowUpstreamDependencies() && (parent instanceof AbstractBuild)) {
        AbstractBuild<?, ?> parentBuild = (AbstractBuild<?,?>)parent;

        Map<AbstractProject, Integer> parentUpstreamBuilds = parentBuild.getUpstreamBuilds();
        for (Map.Entry<AbstractProject, Integer> buildEntry : parentUpstreamBuilds.entrySet()) {
            upstreamBuilds.add(buildEntry.getKey().getBuildByNumber(buildEntry.getValue()));
        }

    }

    for (Run<?, ?> upstreamBuild : upstreamBuilds) {
        if (jobNames.contains(upstreamBuild.getParent().getFullName())) {
            // Use the 'job' parameter instead of directly the 'upstreamBuild', because of Matrix jobs.
            result.add(job.getBuildByNumber(upstreamBuild.getNumber()));
        } else {
            // Figure out the parent job and do a recursive call to getBuild
            result.addAll(getAllUpstreamBuilds(job, context, upstreamBuild));
        }
    }

    return result;
}
项目:DotCi    文件:DynamicBuildFactory.java   
public DynamicBuildFactory upstreamStart(String branch) {
    Cause cause = mock(UpstreamCause.class);
    when(build.getCauses()).thenReturn(Lists.newArrayList(cause));
    addBranchParam(branch);
    return this;
}