public void testNativeMaven() throws Exception { MavenInstallation maven = configureDefaultMaven(); String mavenPath = maven.getHome(); Jenkins.getInstance() .getDescriptorByType(Maven.DescriptorImpl.class) .setInstallations(new MavenInstallation("maven", "THIS IS WRONG", NO_PROPERTIES)); MavenModuleSet project = createMavenProject(); project.setScm(new ExtractResourceSCM(getClass().getResource("/simple-projects.zip"))); project.setAssignedLabel(slave.getSelfLabel()); project.setJDK(jenkins.getJDK("default")); project.setMaven("maven"); project.setGoals("clean"); Run build = project.scheduleBuild2(0).get(); assertBuildStatus(Result.FAILURE, build); ToolLocationNodeProperty property = new ToolLocationNodeProperty( new ToolLocationNodeProperty.ToolLocation( jenkins.getDescriptorByType(MavenInstallation.DescriptorImpl.class), "maven", mavenPath)); slave.getNodeProperties().add(property); build = project.scheduleBuild2(0).get(); System.out.println(build.getLog()); assertBuildStatus(Result.SUCCESS, build); }
@Bug(8415) public void testMaven3Failed() throws Exception { MavenModuleSet m = createMavenProject(); m.setMaven(configureMaven3().getName()); m.setGoals("test -Dmaven.test.failure.ignore=false"); m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimodule-unit-failure.zip"))); assertBuildStatus(Result.FAILURE, m.scheduleBuild2(0).get()); }
@Bug(8415) public void testMaven3Unstable() throws Exception { MavenModuleSet m = createMavenProject(); m.setMaven(configureMaven3().getName()); m.setGoals("test"); m.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimodule-unit-failure.zip"))); assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get()); }
@Bug(5651) public void testNewlinesInOptsRemoved() throws Exception { configureDefaultMaven("apache-maven-2.2.1", MavenInstallation.MAVEN_21); MavenModuleSet m = createMavenProject(); m.setScm(new ExtractResourceSCM(getClass().getResource("maven-surefire-unstable.zip"))); m.setMavenOpts("-XX:MaxPermSize=512m\r\n-Xms128m\r\n-Xmx512m"); m.setGoals("install"); assertBuildStatus(Result.UNSTABLE, m.scheduleBuild2(0).get()); MavenModuleSetBuild pBuild = m.getLastBuild(); assertEquals("Parent build should have Result.UNSTABLE", Result.UNSTABLE, pBuild.getResult()); }
/** Test copying from a particular module of a maven job */ public void testMavenJob() throws Exception { MavenModuleSet mp = setupMavenJob(); assertBuildStatusSuccess(mp.scheduleBuild2(0, new UserCause()).get()); FreeStyleProject p = createProject( mp.getName() + "/org.jvnet.hudson.main.test.multimod$moduleB", "", "", true, false, false); FreeStyleBuild b = p.scheduleBuild2(0, new UserCause()).get(); String dir = "org.jvnet.hudson.main.test.multimod/moduleB/1.0-SNAPSHOT/"; assertFile(true, dir + "moduleB-1.0-SNAPSHOT.jar", b); assertFile(true, dir + "pom.xml", b); }
@Bug(17177) public void testCorrectResultInPostStepAfterFailedPreBuildStep() throws Exception { MavenModuleSet p = createSimpleProject(); MavenInstallation mi = configureDefaultMaven(); p.setMaven(mi.getName()); p.setGoals("initialize"); Shell pre = new Shell("exit 1"); // must fail to simulate scenario! p.getPrebuilders().add(pre); ResultExposingBuilder resultExposer = new ResultExposingBuilder(); p.getPostbuilders().add(resultExposer); assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0).get()); assertEquals( "The result passed to the post build step was not the one from the pre build step", Result.FAILURE, resultExposer.getResult()); }
/** Test copying from maven job where artifacts manually archived instead of automatic */ public void testMavenJobWithArchivePostBuildStep() throws Exception { MavenModuleSet mp = setupMavenJob(); // Turn off automatic archiving and use a post-build step instead. // Artifacts will be stored with the parent build instead of the child module builds. mp.setIsArchivingDisabled(true); mp.getPublishersList().add(new ArtifactArchiver("moduleB/*.xml", "", false)); assertBuildStatusSuccess(mp.scheduleBuild2(0, new UserCause()).get()); FreeStyleProject p = createProject(mp.getName(), "", "", true, false, false); FreeStyleBuild b = p.scheduleBuild2(0, new UserCause()).get(); // Archived artifact should be copied: assertFile(true, "moduleB/pom.xml", b); // None of the maven artifacts should be archived or copied: String dir = "org.jvnet.hudson.main.test.multimod/"; assertFile(false, dir + "moduleA/1.0-SNAPSHOT/moduleA-1.0-SNAPSHOT.jar", b); assertFile(false, dir + "moduleA/1.0-SNAPSHOT/pom.xml", b); assertFile(false, dir + "moduleB/1.0-SNAPSHOT/moduleB-1.0-SNAPSHOT.jar", b); assertFile(false, dir + "moduleB/1.0-SNAPSHOT/pom.xml", b); assertFile(false, dir + "moduleC/1.0-SNAPSHOT/moduleC-1.0-SNAPSHOT.jar", b); assertFile(false, dir + "moduleC/1.0-SNAPSHOT/pom.xml", b); }