Java Code Examples for hudson.matrix.MatrixBuild#getCause()

The following examples show how to use hudson.matrix.MatrixBuild#getCause() . 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: JobHelper.java    From github-integration-plugin with MIT License 5 votes vote down vote up
/**
 * matrix-project requires special extraction.
 */
@CheckForNull
public static <T extends Cause> T ghCauseFromRun(Run<?, ?> run, Class<T> tClass) {
    if (run instanceof MatrixRun) {
        MatrixBuild parentBuild = ((MatrixRun) run).getParentBuild();
        if (nonNull(parentBuild)) {
            return parentBuild.getCause(tClass);
        }
    } else {
        return run.getCause(tClass);
    }

    return null;
}
 
Example 2
Source File: GitLabEnvironmentContributor.java    From gitlab-plugin with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void buildEnvironmentFor(@Nonnull Run r, @Nonnull EnvVars envs, @Nonnull TaskListener listener) throws IOException, InterruptedException {
    GitLabWebHookCause cause = null;
    if (r instanceof MatrixRun) {
        MatrixBuild parent = ((MatrixRun)r).getParentBuild();
        if (parent != null) {
            cause = (GitLabWebHookCause) parent.getCause(GitLabWebHookCause.class);
        }
    } else {
        cause = (GitLabWebHookCause) r.getCause(GitLabWebHookCause.class);
    }
    if (cause != null) {
        envs.overrideAll(cause.getData().getBuildVariables());
    }
}