hudson.model.Cause.UpstreamCause Java Examples
The following examples show how to use
hudson.model.Cause.UpstreamCause.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Common.java From hubot-steps-plugin with Apache License 2.0 | 6 votes |
/** * Return the current build user. * * @param causes build causes. * @param envVars environment variables. * @return user name. */ public static String prepareBuildUserName(List<Cause> causes, EnvVars envVars) { String buildUser = "anonymous"; // For multi branch jobs, while PR building. if (Util.fixEmpty(envVars.get("CHANGE_AUTHOR")) != null) { return envVars.get("CHANGE_AUTHOR"); } 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(); buildUser = prepareBuildUserName(upstreamCauses, envVars); } } return buildUser; }
Example #2
Source File: Common.java From hubot-steps-plugin with Apache License 2.0 | 6 votes |
/** * Retrun the build cause. * * @return build cause. */ public static String prepareBuildCause(List<Cause> causes) { String buildCause = null; if (causes != null && causes.size() > 0) { for (Cause cause : causes) { if (cause instanceof UserIdCause) { buildCause = ((UserIdCause) causes.get(0)).getUserName(); } else if (cause instanceof UpstreamCause) { List<Cause> upstreamCauses = ((UpstreamCause) cause).getUpstreamCauses(); buildCause = prepareBuildCause(upstreamCauses); } else { buildCause = cause.getClass().getSimpleName(); } } } return buildCause == null ? buildCause : buildCause.replace("Cause", ""); }
Example #3
Source File: CommitStatusUpdater.java From gitlab-plugin with GNU General Public License v2.0 | 6 votes |
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(); }
Example #4
Source File: JiraStepExecution.java From jira-steps-plugin with Apache License 2.0 | 5 votes |
/** * Return the current build user. * * @param causes build causes. * @return user name. */ protected static String prepareBuildUserId(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(); buildUser = prepareBuildUserId(upstreamCauses); } } return Util.fixEmpty(buildUser) == null ? "anonymous" : buildUser; }
Example #5
Source File: Common.java From hubot-steps-plugin with Apache License 2.0 | 5 votes |
/** * Return the current build user Id. * * @param causes build causes. * @param envVars environment variables. * @return user name. */ public static String prepareBuildUserId(List<Cause> causes, EnvVars envVars) { String buildUserId = null; if (causes != null && causes.size() > 0) { if (causes.get(0) instanceof UserIdCause) { buildUserId = ((UserIdCause) causes.get(0)).getUserId(); } else if (causes.get(0) instanceof UpstreamCause) { List<Cause> upstreamCauses = ((UpstreamCause) causes.get(0)).getUpstreamCauses(); buildUserId = prepareBuildUserId(upstreamCauses, envVars); } } return buildUserId; }
Example #6
Source File: DynamicBuildFactory.java From DotCi with MIT License | 4 votes |
public DynamicBuildFactory upstreamStart(String branch) { Cause cause = mock(UpstreamCause.class); when(build.getCauses()).thenReturn(Lists.newArrayList(cause)); addBranchParam(branch); return this; }