hudson.matrix.MatrixBuild Java Examples
The following examples show how to use
hudson.matrix.MatrixBuild.
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: LockRunListener.java From lockable-resources-plugin with MIT License | 6 votes |
@Override public void onCompleted(Run<?, ?> build, TaskListener listener) { // Skip unlocking for multiple configuration projects, // only the child jobs will actually unlock resources. if (build instanceof MatrixBuild) return; // obviously project name cannot be obtained here List<LockableResource> required = LockableResourcesManager.get() .getResourcesFromBuild(build); if (!required.isEmpty()) { LockableResourcesManager.get().unlock(required, build); listener.getLogger().printf("%s released lock on %s%n", LOG_PREFIX, required); LOGGER.fine(build.getFullDisplayName() + " released lock on " + required); } }
Example #2
Source File: PipelineApiTest.java From blueocean-plugin with MIT License | 6 votes |
@Test public void matrixProjectTest() throws Exception{ MatrixProject mp = j.jenkins.createProject(MatrixProject.class, "mp1"); mp.getAxes().add(new Axis("os", "linux", "windows")); mp.getAxes().add(new Axis("jdk", "1.7", "1.8")); MatrixBuild matrixBuild = mp.scheduleBuild2(0).get(); j.assertBuildStatusSuccess(matrixBuild); List<Map> pipelines = get("/search/?q=type:pipeline;excludedFromFlattening:jenkins.branch.MultiBranchProject,hudson.matrix.MatrixProject", List.class); Assert.assertEquals(1, pipelines.size()); Map p = pipelines.get(0); Assert.assertEquals("mp1", p.get("name")); String href = getHrefFromLinks(p, "self"); Assert.assertEquals("/job/mp1/", href); }
Example #3
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 #4
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 #5
Source File: JUnitResultArchiverTest.java From junit-plugin with MIT License | 6 votes |
@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 #6
Source File: MatrixBridge.java From warnings-ng-plugin with MIT License | 5 votes |
@Override public MatrixAggregator createAggregator(final MatrixBuild build, final Launcher launcher, final BuildListener listener) { IssuesRecorder recorder = build.getParent().getPublishersList().get(IssuesRecorder.class); if (recorder == null) { return null; } return new IssuesAggregator(build, launcher, listener, recorder); }
Example #7
Source File: TemplateUtils.java From ez-templates with Apache License 2.0 | 5 votes |
/** * 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 #8
Source File: LockRunListener.java From lockable-resources-plugin with MIT License | 5 votes |
@Override public void onDeleted(Run<?, ?> build) { // Skip unlocking for multiple configuration projects, // only the child jobs will actually unlock resources. if (build instanceof MatrixBuild) return; List<LockableResource> required = LockableResourcesManager.get() .getResourcesFromBuild(build); if (!required.isEmpty()) { LockableResourcesManager.get().unlock(required, build); LOGGER.fine(build.getFullDisplayName() + " released lock on " + required); } }
Example #9
Source File: TestUtility.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
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); }
Example #10
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 #11
Source File: MergeRequestNotifier.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
public MatrixAggregator createAggregator(MatrixBuild build, Launcher launcher, BuildListener listener) { return new MatrixAggregator(build, launcher, listener) { @Override public boolean endBuild() throws InterruptedException, IOException { perform(build, launcher, listener); return super.endBuild(); } }; }
Example #12
Source File: GitLabCommitStatusPublisher.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
public MatrixAggregator createAggregator(MatrixBuild build, Launcher launcher, BuildListener listener) { return new MatrixAggregator(build, launcher, listener) { @Override public boolean endBuild() throws InterruptedException, IOException { perform(build, launcher, listener); return super.endBuild(); } }; }
Example #13
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 #14
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 #15
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 #16
Source File: MatrixMultiBranchProject.java From multi-branch-project-plugin with MIT License | 4 votes |
@Nonnull @Override protected BranchProjectFactory<MatrixProject, MatrixBuild> newProjectFactory() { return new MatrixBranchProjectFactory(); }
Example #17
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)); } } }
Example #18
Source File: LockRunListener.java From lockable-resources-plugin with MIT License | 4 votes |
@Override public void onStarted(Run<?, ?> build, TaskListener listener) { // Skip locking for multiple configuration projects, // only the child jobs will actually lock resources. if (build instanceof MatrixBuild) return; if (build instanceof AbstractBuild) { Job<?, ?> proj = Utils.getProject(build); Set<LockableResource> required = new HashSet<>(); if (proj != null) { LockableResourcesStruct resources = Utils.requiredResources(proj); if (resources != null) { if (resources.requiredNumber != null || !resources.label.isEmpty() || resources.getResourceMatchScript() != null) { required.addAll(LockableResourcesManager.get(). getResourcesFromProject(proj.getFullName())); } else { required.addAll(resources.required); } if (LockableResourcesManager.get().lock(required, build, null)) { build.addAction(LockedResourcesBuildAction .fromResources(required)); listener.getLogger().printf("%s acquired lock on %s%n", LOG_PREFIX, required); LOGGER.fine(build.getFullDisplayName() + " acquired lock on " + required); if (resources.requiredVar != null) { build.addAction(new ResourceVariableNameAction(new StringParameterValue( resources.requiredVar, required.toString().replaceAll("[\\]\\[]", "")))); } } else { listener.getLogger().printf("%s failed to lock %s%n", LOG_PREFIX, required); LOGGER.fine(build.getFullDisplayName() + " failed to lock " + required); } } } } }
Example #19
Source File: IssuesAggregatorTest.java From warnings-ng-plugin with MIT License | 4 votes |
private IssuesAggregator createIssueAggregator(final IssuesRecorder recorder) { return new IssuesAggregator(mock(MatrixBuild.class), mock(Launcher.class), mock( BuildListener.class), recorder); }
Example #20
Source File: IssuesAggregator.java From warnings-ng-plugin with MIT License | 3 votes |
/** * Creates a new instance of {@link IssuesAggregator}. * * @param build * the associated matrix build * @param launcher * the launcher to communicate with the build agent * @param listener * the listener to log messages to * @param recorder * the recorder that actually scans for issues and records the found issues */ public IssuesAggregator(final MatrixBuild build, final Launcher launcher, final BuildListener listener, final IssuesRecorder recorder) { super(build, launcher, listener); this.recorder = recorder; }