hudson.matrix.MatrixRun Java Examples
The following examples show how to use
hudson.matrix.MatrixRun.
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: GitHubPollingLogAction.java From github-integration-plugin with MIT License | 6 votes |
@Nonnull public File getPollingLogFile() { File pollingFile; if (nonNull(job)) { pollingFile = job.getRootDir(); } else if (run instanceof MatrixRun) { MatrixRun matrixRun = (MatrixRun) run; pollingFile = matrixRun.getParentBuild().getRootDir(); } else if (run instanceof MatrixBuild) { pollingFile = run.getRootDir(); } else if (nonNull(run)) { pollingFile = run.getRootDir(); } else { throw new IllegalStateException("Can't get polling log file: no run or job initialised"); } return new File(pollingFile, getPollingFileName()); }
Example #2
Source File: GitLabEnvironmentContributorTest.java From gitlab-plugin with GNU General Public License v2.0 | 6 votes |
@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: IssuesAggregator.java From warnings-ng-plugin with MIT License | 5 votes |
@Override public boolean endRun(final MatrixRun run) { aggregationTableLock.lock(); try { names.add(run.getParent().getName()); List<ResultAction> actions = run.getActions(ResultAction.class); for (ResultAction action : actions) { resultsPerTool.put(action.getId(), createReport(action.getId(), action.getResult())); } } finally { aggregationTableLock.unlock(); } return true; }
Example #4
Source File: MatrixJobITest.java From warnings-ng-plugin with MIT License | 5 votes |
/** * 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 #5
Source File: IssuesAggregatorTest.java From warnings-ng-plugin with MIT License | 5 votes |
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 #6
Source File: JobHelper.java From github-integration-plugin with MIT License | 5 votes |
/** * 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 #7
Source File: MatrixProjectITest.java From github-integration-plugin with MIT License | 5 votes |
@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 #8
Source File: GitLabEnvironmentContributor.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
@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()); } }
Example #9
Source File: IssuesAggregatorTest.java From warnings-ng-plugin with MIT License | 4 votes |
@Test void shouldHandleBuildWithoutActions() { IssuesRecorder recorder = mock(IssuesRecorder.class); IssuesAggregator aggregator = createIssueAggregator(recorder); MatrixRun build = createBuild(AXIS_WINDOWS); aggregator.endRun(build); assertThat(aggregator.getNames()).containsExactly(AXIS_WINDOWS); assertThat(aggregator.getResultsPerTool()).isEmpty(); aggregator.endBuild(); verify(recorder, never()).publishResult(any(), any(), anyString(), any(), anyString(), any()); }
Example #10
Source File: IssuesAggregatorTest.java From warnings-ng-plugin with MIT License | 4 votes |
private MatrixRun createBuild(final String axis, final ResultAction... actions) { MatrixRun build = createBuild(axis); when(build.getActions(ResultAction.class)).thenReturn(Arrays.asList(actions)); return build; }
Example #11
Source File: JobRunnerForCause.java From github-integration-plugin with MIT License | 4 votes |
public synchronized int abortRunning(int number) throws IllegalAccessException { int aborted = 0; Computer[] computers = getJenkinsInstance().getComputers(); for (Computer computer : computers) { if (isNull(computer)) { continue; } List<Executor> executors = computer.getExecutors(); executors.addAll(computer.getOneOffExecutors()); for (Executor executor : executors) { if (isNull(executor) || !executor.isBusy() || nonNull(executor.getCauseOfDeath()) || !getInterruptCauses(executor).isEmpty() || getInterruptStatus(executor) == Result.ABORTED) { continue; } Queue.Executable executable = executor.getCurrentExecutable(); final SubTask parent = executable.getParent(); if (!(executable instanceof Run)) { continue; } final Run executableRun = (Run) executable; if (!(parent instanceof Job)) { continue; } final Job parentJob = (Job) parent; if (!parentJob.getFullName().equals(job.getFullName())) { // name doesn't match continue; } if (executableRun.getResult() == Result.ABORTED) { // was already aborted continue; } if (executableRun instanceof MatrixRun) { // the whole MatrixBuild will be aborted continue; } // if (executable instanceof MatrixBuild) { // final MatrixBuild executable1 = (MatrixBuild) executable; // executable1.doStop() // } final GitHubPRCause causeAction = (GitHubPRCause) executableRun.getCause(GitHubPRCause.class); if (nonNull(causeAction) && causeAction.getNumber() == number) { LOGGER.info("Aborting '{}', by interrupting '{}'", executableRun, executor); executor.interrupt(Result.ABORTED, new NewPRInterruptCause()); aborted++; } } } return aborted; }
Example #12
Source File: AbortRunningJobRunnerCauseTest.java From github-integration-plugin with MIT License | 4 votes |
@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)); } } }