hudson.matrix.MatrixConfiguration Java Examples

The following examples show how to use hudson.matrix.MatrixConfiguration. 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 6 votes vote down vote up
/**
 * support matrix plugin.
 *
 * @see JobInfoHelpers#triggerFrom(hudson.model.Job, java.lang.Class)
 */
@CheckForNull
public static <T extends Trigger> T triggerFrom(final Job<?, ?> job, Class<T> tClass) {
    Job<?, ?> guessJob;
    if (job instanceof MatrixConfiguration) {
        guessJob = ((MatrixConfiguration) job).getParent();
    } else {
        guessJob = job;
    }

    if (guessJob instanceof AbstractProject<?, ?>) {
        final AbstractProject<?, ?> abstractProject = (AbstractProject<?, ?>) guessJob;
        return abstractProject.getTrigger(tClass);
    } else if (guessJob instanceof ParameterizedJobMixIn.ParameterizedJob) {
        ParameterizedJobMixIn.ParameterizedJob pJob = (ParameterizedJobMixIn.ParameterizedJob) guessJob;

        for (Object candidate : pJob.getTriggers().values()) {
            if (tClass.isInstance(candidate)) {
                return tClass.cast(candidate);
            }
        }
    }
    return null;
}
 
Example #2
Source File: Utils.java    From lockable-resources-plugin with MIT License 6 votes vote down vote up
public static LockableResourcesStruct requiredResources(
		Job<?, ?> project) {
	RequiredResourcesProperty property = null;
	EnvVars env = new EnvVars();

	if (project instanceof MatrixConfiguration) {
		env.putAll(((MatrixConfiguration) project).getCombination());
		project = (Job<?, ?>) project.getParent();
	}

	property = project.getProperty(RequiredResourcesProperty.class);
	if (property != null)
		return new LockableResourcesStruct(property, env);

	return null;
}
 
Example #3
Source File: IssuesAggregatorTest.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
private MatrixRun createBuild(final String axis1) {
    MatrixRun build = mock(MatrixRun.class);
    MatrixConfiguration configuration = mock(MatrixConfiguration.class);
    when(build.getParent()).thenReturn(configuration);
    when(configuration.getName()).thenReturn(axis1);
    return build;
}
 
Example #4
Source File: TestUtility.java    From gitlab-plugin with GNU General Public License v2.0 5 votes vote down vote up
static <T  extends Notifier & MatrixAggregatable> void verifyMatrixAggregatable(Class<T> publisherClass, BuildListener listener) throws InterruptedException, IOException {
    AbstractBuild build = mock(AbstractBuild.class);
    AbstractProject project = mock(MatrixConfiguration.class);
    Notifier publisher = mock(publisherClass);
    MatrixBuild parentBuild = mock(MatrixBuild.class);

    when(build.getParent()).thenReturn(project);
    when(((MatrixAggregatable) publisher).createAggregator(any(MatrixBuild.class), any(Launcher.class), any(BuildListener.class))).thenCallRealMethod();
    when(publisher.perform(any(AbstractBuild.class), any(Launcher.class), any(BuildListener.class))).thenReturn(true);

    MatrixAggregator aggregator = ((MatrixAggregatable) publisher).createAggregator(parentBuild, null, listener);
    aggregator.startBuild();
    aggregator.endBuild();
    verify(publisher).perform(parentBuild, null, listener);
}