hudson.matrix.AxisList Java Examples

The following examples show how to use hudson.matrix.AxisList. 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: JUnitResultArchiverTest.java    From junit-plugin with MIT License 6 votes vote down vote up
@Test public void specialCharsInRelativePath() throws Exception {
    Assume.assumeFalse(Functions.isWindows());
    final String ID_PREFIX = "test-../a=%3C%7C%23)/testReport/org.twia.vendor/VendorManagerTest/testCreateAdjustingFirm/";
    final String EXPECTED = "org.twia.dao.DAOException: [S2001] Hibernate encountered an error updating Claim [null]";

    MatrixProject p = j.jenkins.createProject(MatrixProject.class, "test-" + j.jenkins.getItems().size());
    p.setAxes(new AxisList(new TextAxis("a", "<|#)")));
    p.setScm(new SingleFileSCM("report.xml", getClass().getResource("junit-report-20090516.xml")));
    p.getPublishersList().add(new JUnitResultArchiver("report.xml"));

    MatrixBuild b = p.scheduleBuild2(0).get();
    j.assertBuildStatus(Result.UNSTABLE, b);

    WebClient wc = j.createWebClient();
    HtmlPage page = wc.getPage(b, "testReport");

    assertThat(page.asText(), not(containsString(EXPECTED)));

    ((HtmlAnchor) page.getElementById(ID_PREFIX + "-showlink")).click();
    wc.waitForBackgroundJavaScript(10000L);
    assertThat(page.asText(), containsString(EXPECTED));

    ((HtmlAnchor) page.getElementById(ID_PREFIX + "-hidelink")).click();
    wc.waitForBackgroundJavaScript(10000L);
    assertThat(page.asText(), not(containsString(EXPECTED)));
}
 
Example #2
Source File: GitLabEnvironmentContributorTest.java    From gitlab-plugin with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void matrixProjectTest() throws IOException, InterruptedException, ExecutionException {
    EnvVars env;
    MatrixProject p = jenkins.jenkins.createProject(MatrixProject.class, "matrixbuild");
    GitLabWebHookCause cause = new GitLabWebHookCause(generateCauseData());
    // set up 2x2 matrix
    AxisList axes = new AxisList();
    axes.add(new TextAxis("db","mysql","oracle"));
    axes.add(new TextAxis("direction","north","south"));
    p.setAxes(axes);

    MatrixBuild build = p.scheduleBuild2(0, cause).get();
    List<MatrixRun> runs = build.getRuns();
    assertEquals(4,runs.size());
    for (MatrixRun run : runs) {
        env = run.getEnvironment(listener);
        assertNotNull(env.get("db"));
        assertEnv(env);
    }
}
 
Example #3
Source File: MatrixJobITest.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
/**
 * Build a matrix job with three configurations. For each configuration a different set of warnings will be parsed
 * with the same parser (GCC). After the successful build the total number of warnings at the root level should be
 * set to 12 (sum of all three configurations). Moreover, for each configuration the total number of warnings is
 * also verified (4, 6, and 2 warnings).
 *
 * @throws Exception in case of an error
 */
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
@Test
public void shouldCreateIndividualAxisResults() throws Exception {
    MatrixProject project = createProject(MatrixProject.class);
    copySingleFileToWorkspace(project, "matrix-warnings-one.txt", "user_axis/one/warnings.txt");
    copySingleFileToWorkspace(project, "matrix-warnings-two.txt", "user_axis/two/warnings.txt");
    copySingleFileToWorkspace(project, "matrix-warnings-three.txt", "user_axis/three/warnings.txt");
    IssuesRecorder publisher = new IssuesRecorder();
    Gcc4 tool = new Gcc4();
    tool.setPattern("**/*.txt");
    publisher.setTools(tool);
    project.getPublishersList().add(publisher);

    AxisList axis = new AxisList();
    TextAxis userAxis = new TextAxis("user_axis", "one two three");
    axis.add(userAxis);
    project.setAxes(axis);

    Map<String, Integer> warningsPerAxis = new HashMap<>();
    warningsPerAxis.put("one", 4);
    warningsPerAxis.put("two", 6);
    warningsPerAxis.put("three", 2);

    MatrixBuild build = project.scheduleBuild2(0).get();
    for (MatrixRun run : build.getRuns()) {
        getJenkins().assertBuildStatus(Result.SUCCESS, run);

        AnalysisResult result = getAnalysisResult(run);

        String currentAxis = run.getBuildVariables().values().iterator().next();
        assertThat(result.getTotalSize()).as("Result of axis " + currentAxis).isEqualTo(warningsPerAxis.get(currentAxis));
    }
    AnalysisResult aggregation = getAnalysisResult(build);
    assertThat(aggregation.getTotalSize()).isEqualTo(12);
}
 
Example #4
Source File: MatrixProjectITest.java    From github-integration-plugin with MIT License 5 votes vote down vote up
@Test
public void testChildStatuses() throws Exception {
    final MatrixProject matrixProject = jRule.jenkins.createProject(MatrixProject.class, "matrix-project");

    matrixProject.addProperty(getPreconfiguredProperty(ghRule.getGhRepo()));
    matrixProject.addTrigger(getPreconfiguredPRTrigger());

    matrixProject.getBuildersList().add(new GitHubPRStatusBuilder());
    matrixProject.getBuildersList().add(new Shell("sleep 10"));

    matrixProject.getPublishersList().add(new GitHubPRBuildStatusPublisher());
    matrixProject.getPublishersList().add(new GitHubPRCommentPublisher(new GitHubPRMessage("Comment"), null, null));

    matrixProject.setAxes(
            new AxisList(
                    new TextAxis("first_axis", "first_value1", "first_value2"),
                    new TextAxis("second_axis", "sec_value1", "sec_value2")
            )
    );

    matrixProject.save();

    super.basicTest(matrixProject);

    for (MatrixBuild build : matrixProject.getBuilds()) {
        for (MatrixRun matrixRun : build.getRuns()) {
            jRule.assertLogNotContains("\tat", matrixRun);
        }
    }
}
 
Example #5
Source File: AxisListConverter.java    From DotCi with MIT License 5 votes vote down vote up
@Override
public Object decode(Class targetClass, Object fromDBObject, MappedField optionalExtraInfo) {
    if (fromDBObject == null) return null;

    BasicDBList rawList = (BasicDBList) fromDBObject;

    AxisList axisList = new AxisList();
    for (Object obj : rawList) {
        DBObject dbObj = (DBObject) obj;
        axisList.add((Axis) getMapper().fromDBObject(optionalExtraInfo.getSubClass(), dbObj, getMapper().createEntityCache()));
    }

    return axisList;
}
 
Example #6
Source File: AxisListConverter.java    From DotCi with MIT License 5 votes vote down vote up
@Override
public Object encode(Object value, MappedField optionalExtraInfo) {
    if (value == null) return null;

    AxisList axisList = (AxisList) value;

    BasicDBList convertedList = new BasicDBList();

    for (Axis axis : axisList) {
        convertedList.add(getMapper().toDBObject(axis));
    }

    return convertedList;
}
 
Example #7
Source File: DynamicBuild.java    From DotCi with MIT License 5 votes vote down vote up
public void setAxisList(final AxisList axisList) {
    this.axisList = axisList;
    try {
        save();
    } catch (final IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example #8
Source File: TemplateUtils.java    From ez-templates with Apache License 2.0 5 votes vote down vote up
/**
 * Inlined from {@link MatrixProject#setAxes(hudson.matrix.AxisList)} except it doesn't call save.
 *
 * @param matrixProject The project to set the Axis on.
 * @param axisList      The Axis list to set.
 */
private static void fixAxisList(MatrixProject matrixProject, AxisList axisList) {
    if (axisList == null) {
        return; //The "axes" field can never be null. So just to be extra careful.
    }
    ReflectionUtils.setFieldValue(MatrixProject.class, matrixProject, "axes", axisList);

    //noinspection unchecked
    ReflectionUtils.invokeMethod(MatrixProject.class, matrixProject, "rebuildConfigurations", ReflectionUtils.MethodParameter.get(MatrixBuild.MatrixBuildExecution.class, null));
}
 
Example #9
Source File: AbortRunningJobRunnerCauseTest.java    From github-integration-plugin with MIT License 4 votes vote down vote up
@Test
@RandomlyFails(value = "No idea why matrix doesn't work normally")
public void testAbortRunningMatrixProject() throws Exception {

    MockFolder folder = j.createFolder("Matrix_folder");

    MatrixProject job1 = folder.createProject(MatrixProject.class, "project1");
    job1.setDisplayName("project1 display name");
    job1.setConcurrentBuild(true);
    job1.getBuildersList().add(new SleepBuilder());
    job1.setAxes(
            new AxisList(
                    new TextAxis("first_axis", "first_value1"),
                    new TextAxis("second_axis", "sec_value1")
            )
    );
    configRoundTripUnsecure(job1);
    job1.save();

    MatrixProject job2 = folder.createProject(MatrixProject.class, "project2");
    job2.setDisplayName("project1 display name");
    job2.setConcurrentBuild(true);
    job2.getBuildersList().add(new SleepBuilder());
    job2.setAxes(
            new AxisList(
                    new TextAxis("first_axis", "first_value1"),
                    new TextAxis("second_axis", "sec_value1")
            )
    );
    configRoundTripUnsecure(job2);
    job2.save();

    MatrixProject job3 = folder.createProject(MatrixProject.class, "project3");
    job3.setDisplayName("project1 display name");
    job3.setConcurrentBuild(true);
    job3.getBuildersList().add(new SleepBuilder());
    job3.setAxes(
            new AxisList(
                    new TextAxis("first_axis", "first_value1"),
                    new TextAxis("second_axis", "sec_value1")
            )
    );
    configRoundTripUnsecure(job3);
    job3.save();

    testAbortRunning(job1, job2, job3);

    assertThat(job1.getBuilds(), hasSize(3));

    for (MatrixBuild matrixBuild : job1.getBuilds()) {
        assertThat(matrixBuild.getResult(), is(Result.ABORTED));
        assertThat(matrixBuild.getRuns(), not(empty()));
        for (MatrixRun matrixRun : matrixBuild.getRuns()) {
            assertThat(matrixRun.getResult(), is(Result.ABORTED));
        }
    }
}
 
Example #10
Source File: AxisListConverter.java    From DotCi with MIT License 4 votes vote down vote up
public AxisListConverter() {
    super(AxisList.class);
}
 
Example #11
Source File: BuildConfiguration.java    From DotCi with MIT License 4 votes vote down vote up
public AxisList getAxisList() {
    return this.runSection.getAxisList();
}
 
Example #12
Source File: DynamicBuildLayouter.java    From DotCi with MIT License 4 votes vote down vote up
public DynamicBuildLayouter(AxisList axisList, DynamicBuild dynamicBuild) {
    super(axisList == null ? new AxisList() : axisList);
    this.axisList = axisList;
    this.dynamicBuild = dynamicBuild;
}
 
Example #13
Source File: DynamicBuildLayouter.java    From DotCi with MIT License 4 votes vote down vote up
public Iterable<Combination> list() {
    return axisList == null ? new AxisList().list() : axisList.list();
}
 
Example #14
Source File: TemplateUtils.java    From ez-templates with Apache License 2.0 4 votes vote down vote up
public static void handleTemplateImplementationSaved(AbstractProject implementationProject, TemplateImplementationProperty property) throws IOException {
	
    if (property.getTemplateJobName().equals("null")) {
        LOG.warning(String.format("Implementation [%s] was saved. No template selected.", implementationProject.getFullDisplayName()));
        return;
    }
	
    LOG.info(String.format("Implementation [%s] was saved. Syncing with [%s].", implementationProject.getFullDisplayName(), property.getTemplateJobName()));
    
    AbstractProject templateProject = property.findTemplate();        
    if (templateProject == null) {
    	
    	// If the template can't be found, then it's probably a bug
        throw new IllegalStateException(String.format("Cannot find template [%s] used by job [%s]", property.getTemplateJobName(), implementationProject.getFullDisplayName()));
    }

    //Capture values we want to keep
    @SuppressWarnings("unchecked")
    boolean implementationIsTemplate = implementationProject.getProperty(TemplateProperty.class) != null;
    List<ParameterDefinition> oldImplementationParameters = findParameters(implementationProject);
    @SuppressWarnings("unchecked")
    Map<TriggerDescriptor, Trigger> oldTriggers = implementationProject.getTriggers();
    boolean shouldBeDisabled = implementationProject.isDisabled();
    String description = implementationProject.getDescription();
    String displayName = implementationProject.getDisplayNameOrNull();
    AuthorizationMatrixProperty oldAuthMatrixProperty = (AuthorizationMatrixProperty) implementationProject.getProperty(AuthorizationMatrixProperty.class);
    SCM oldScm = (SCM) implementationProject.getScm();
    JobProperty oldOwnership = implementationProject.getProperty("com.synopsys.arc.jenkins.plugins.ownership.jobs.JobOwnerJobProperty");
    Label oldLabel = implementationProject.getAssignedLabel();

    AxisList oldAxisList = null;
    if (implementationProject instanceof MatrixProject && !property.getSyncMatrixAxis()) {
        MatrixProject matrixProject = (MatrixProject) implementationProject;
        oldAxisList = matrixProject.getAxes();
    }

    implementationProject = synchronizeConfigFiles(implementationProject, templateProject);

    // Reverse all the fields that we've marked as "Don't Sync" so that they appear that they haven't changed.

    //Set values that we wanted to keep via reflection to prevent infinite save recursion
    fixProperties(implementationProject, property, implementationIsTemplate);
    fixParameters(implementationProject, oldImplementationParameters);

    ReflectionUtils.setFieldValue(AbstractItem.class, implementationProject, "displayName", displayName);

    if (!property.getSyncBuildTriggers()) {
        fixBuildTriggers(implementationProject, oldTriggers);
    }

    if (!property.getSyncDisabled()) {
        ReflectionUtils.setFieldValue(AbstractProject.class, implementationProject, "disabled", shouldBeDisabled);
    }

    if (oldAxisList != null && implementationProject instanceof MatrixProject && !property.getSyncMatrixAxis()) {
        fixAxisList((MatrixProject) implementationProject, oldAxisList);
    }

    if (!property.getSyncDescription() && description != null) {
        ReflectionUtils.setFieldValue(AbstractItem.class, implementationProject, "description", description);
    }

    if (!property.getSyncSecurity() && oldAuthMatrixProperty != null) {
        implementationProject.removeProperty(AuthorizationMatrixProperty.class);
        implementationProject.addProperty(oldAuthMatrixProperty);
    }

    if (!property.getSyncScm() && oldScm != null) {
        implementationProject.setScm(oldScm);
    }

    if (!property.getSyncOwnership() && oldOwnership != null) {
        implementationProject.removeProperty(oldOwnership.getClass());
        implementationProject.addProperty(oldOwnership);
    }

    if (!property.getSyncAssignedLabel()) {
        implementationProject.setAssignedLabel(oldLabel);
    }

    if (Jenkins.getInstance().getPlugin("promoted-builds") != null) {
        PromotedBuildsTemplateUtils.addPromotions(implementationProject, templateProject);
    } 

    ProjectUtils.silentSave(implementationProject);
}