/** * Verifies dependency build ordering of SNAPSHOT dependency. Note - has to build the projects * once each first in order to get dependency info. */ public void testSnapshotInDependencyManagementBuildTrigger() throws Exception { configureDefaultMaven(); MavenModuleSet projA = createMavenProject("snap-dep-test-up"); projA.setGoals("clean install"); projA.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-A.zip"))); MavenModuleSet projB = createMavenProject("snap-dep-test-down"); projB.setGoals("clean install"); projB.setIgnoreUpstremChanges(false); projB.setQuietPeriod(0); projB.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-D.zip"))); buildAndAssertSuccess(projA); buildAndAssertSuccess(projB); projA.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-A-changed.zip"))); buildAndAssertSuccess(projA); // at this point runB2 should be in the queue, so wait until that completes. waitUntilNoActivityUpTo(90 * 1000); assertEquals( "Expected most recent build of second project to be #2", 2, projB.getLastBuild().getNumber()); }
/** Check if the generated site is linked correctly for multi module projects. */ public void testMultiModuleSiteBuild() throws Exception { MavenModuleSet project = createProject("maven-multimodule-site.zip"); project.setGoals("site"); try { buildAndAssertSuccess(project); } catch (InterruptedException x) { // jglick: when using M2 this just hangs on my machine (pool-*-thread-* in // java.net.SocketInputStream.socketRead0); sometimes passes in M3, but not consistently, and // very very slowly when it does (network dependency) return; // TODO use JenkinsRule and throw AssumptionViolatedException } // this should succeed HudsonTestCase.WebClient wc = new WebClient(); wc.getPage(project, "site"); wc.getPage(project, "site/core"); wc.getPage(project, "site/client"); // @Bug(7577): check that site generation succeeds also if only a single module is build MavenModule coreModule = project.getModule("mmtest:core"); Assert.assertEquals("site", coreModule.getGoals()); try { buildAndAssertSuccess(coreModule); } catch (InterruptedException x) { return; // TODO as above } wc.getPage(project, "site/core"); }
public void testOnSlave() throws Exception { MavenModuleSet project = createSimpleProject(); project.setGoals("validate"); project.setAssignedLabel(createSlave().getSelfLabel()); buildAndAssertSuccess(project); }
private MavenModuleSet setupMavenJob() throws Exception { configureDefaultMaven(); MavenModuleSet mp = createMavenProject(); mp.setGoals("clean package"); mp.setScm(new ExtractResourceSCM(getClass().getResource("maven-job.zip"))); return mp; }
private MavenModuleSet createProject(final String scmResource) throws Exception { MavenModuleSet project = createMavenProject(); MavenInstallation mi = configureDefaultMaven(); project.setScm(new ExtractResourceSCM(getClass().getResource(scmResource))); project.setMaven(mi.getName()); project.setLocalRepository(new PerJobLocalRepositoryLocator()); return project; }
@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(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()); }
public void testOnMaster() throws Exception { MavenModuleSet project = createSimpleProject(); project.setGoals("validate"); buildAndAssertSuccess(project); String xml = project.getModules().iterator().next().getConfigFile().asString(); assertTrue(xml, xml.contains("<maven2")); assertFalse(xml, xml.contains("<maven2-module-set")); }
@Bug(7261) public void testAbsolutePathPom() throws Exception { File pom = new File(this.getClass().getResource("test-pom-7162.xml").toURI()); MavenModuleSet project = createMavenProject(); MavenInstallation mi = configureDefaultMaven(); project.setMaven(mi.getName()); project.setRootPOM(pom.getAbsolutePath()); project.setGoals("install"); buildAndAssertSuccess(project); }
public void testGlobalMavenOpts() throws Exception { configureDefaultMaven(); MavenModuleSet m = createMavenProject(); m.setScm(new ExtractResourceSCM(getClass().getResource("maven-opts-echo.zip"))); m.setGoals("validate"); m.DESCRIPTOR.setGlobalMavenOpts("-Dhudson.mavenOpt.test=bar"); buildAndAssertSuccess(m); assertLogContains("[hudson.mavenOpt.test=bar]", m.getLastBuild()); }
public void testEnvMavenOptsNoneInProject() throws Exception { configureDefaultMaven(); MavenModuleSet m = createMavenProject(); m.setScm(new ExtractResourceSCM(getClass().getResource("maven-opts-echo.zip"))); m.setGoals("validate"); m.setAssignedLabel( createSlave(new EnvVars("MAVEN_OPTS", "-Dhudson.mavenOpt.test=foo")).getSelfLabel()); buildAndAssertSuccess(m); assertLogContains("[hudson.mavenOpt.test=foo]", m.getLastBuild()); }
/** Check if the generated site is linked correctly. */ @Bug(3497) public void testSiteBuild() throws Exception { MavenModuleSet project = createSimpleProject(); project.setGoals("site"); buildAndAssertSuccess(project); // this should succeed HudsonTestCase.WebClient wc = new WebClient(); wc.getPage(project, "site"); wc.assertFails(project.getUrl() + "site/no-such-file", HttpURLConnection.HTTP_NOT_FOUND); }
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); }
/** 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); }
/** Check if the the site goal will work when run from a slave. */ @Bug(5943) public void testMultiModuleSiteBuildOnSlave() throws Exception { MavenModuleSet project = createProject("maven-multimodule-site.zip"); project.setGoals("site"); project.setAssignedLabel(createSlave().getSelfLabel()); try { buildAndAssertSuccess(project); } catch (InterruptedException x) { return; // TODO as above } // this should succeed HudsonTestCase.WebClient wc = new WebClient(); wc.getPage(project, "site"); wc.getPage(project, "site/core"); wc.getPage(project, "site/client"); }
public void testNestedMultiModuleSiteBuild() throws Exception { MavenModuleSet project = createProject("maven-nested-multimodule-site.zip"); project.setGoals("site"); try { buildAndAssertSuccess(project); } catch (InterruptedException x) { return; // TODO as above } // this should succeed HudsonTestCase.WebClient wc = new WebClient(); wc.getPage(project, "site"); wc.getPage(project, "site/core"); wc.getPage(project, "site/client"); wc.getPage(project, "site/client/nested1"); wc.getPage(project, "site/client/nested1/nested2"); }
/** 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); }
@Bug(6779) public void testDeleteSetBuildDeletesModuleBuilds() throws Exception { MavenModuleSet project = createProject("maven-multimod.zip"); project.setLocalRepository(new DefaultLocalRepositoryLocator()); project.setGoals("install"); buildAndAssertSuccess(project); buildAndAssertSuccess(project.getModule("org.jvnet.hudson.main.test.multimod:moduleB")); buildAndAssertSuccess(project); assertEquals(2, project.getBuilds().size()); // Module build does not add a ModuleSetBuild project.getFirstBuild().delete(); // A#1, B#1 and B#2 should all be deleted too assertEquals( 1, project.getModule("org.jvnet.hudson.main.test.multimod:moduleA").getBuilds().size()); assertEquals( 1, project.getModule("org.jvnet.hudson.main.test.multimod:moduleB").getBuilds().size()); }
/** Config roundtrip test around pre/post build step */ public void testConfigRoundtrip() throws Exception { MavenModuleSet m = createMavenProject(); Shell b1 = new Shell("1"); Shell b2 = new Shell("2"); m.getPrebuilders().add(b1); m.getPostbuilders().add(b2); configRoundtrip((Item) m); assertEquals(1, m.getPrebuilders().size()); assertNotSame(b1, m.getPrebuilders().get(Shell.class)); assertEquals("1", m.getPrebuilders().get(Shell.class).getCommand()); assertEquals(1, m.getPostbuilders().size()); assertNotSame(b2, m.getPostbuilders().get(Shell.class)); assertEquals("2", m.getPostbuilders().get(Shell.class).getCommand()); for (Result r : new Result[] {Result.SUCCESS, Result.UNSTABLE, Result.FAILURE}) { m.setRunPostStepsIfResult(r); configRoundtrip((Item) m); assertEquals(r, m.getRunPostStepsIfResult()); } }
@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()); }
@Bug(16499) public void testCopyFromExistingMavenProject() throws Exception { MavenModuleSet project = createSimpleProject(); project.setGoals("abcdefg"); project.save(); MavenModuleSet copy = (MavenModuleSet) Jenkins.getInstance() .copy((AbstractProject<?, ?>) project, "copy" + System.currentTimeMillis()); assertNotNull("Copied project must not be null", copy); assertEquals(project.getGoals(), copy.getGoals()); }
@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()); }
public void testDefaultSettingsProvider() throws Exception { { MavenModuleSet m = createMavenProject(); assertNotNull(m); assertEquals(DefaultSettingsProvider.class, m.getSettings().getClass()); assertEquals(DefaultGlobalSettingsProvider.class, m.getGlobalSettings().getClass()); } { GlobalMavenConfig globalMavenConfig = GlobalMavenConfig.get(); assertNotNull("No global Maven Config available", globalMavenConfig); globalMavenConfig.setSettingsProvider(new FilePathSettingsProvider("/tmp/settigns.xml")); globalMavenConfig.setGlobalSettingsProvider( new FilePathGlobalSettingsProvider("/tmp/global-settigns.xml")); MavenModuleSet m = createMavenProject(); assertEquals(FilePathSettingsProvider.class, m.getSettings().getClass()); assertEquals("/tmp/settigns.xml", ((FilePathSettingsProvider) m.getSettings()).getPath()); assertEquals( "/tmp/global-settigns.xml", ((FilePathGlobalSettingsProvider) m.getGlobalSettings()).getPath()); } }
/** * Verifies dependency build ordering of multiple SNAPSHOT dependencies. Note - has to build the * projects once each first in order to get dependency info. B depends on A, C depends on A and B. * Build order should be A->B->C. */ public void testMixedTransitiveSnapshotTrigger() throws Exception { configureDefaultMaven(); MavenModuleSet projA = createMavenProject("snap-dep-test-up"); projA.setGoals("clean install"); projA.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-A.zip"))); MavenModuleSet projB = createMavenProject("snap-dep-test-mid"); projB.setGoals("clean install"); projB.setIgnoreUpstremChanges(false); projB.setQuietPeriod(0); projB.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-B.zip"))); MavenModuleSet projC = createMavenProject("snap-dep-test-down"); projC.setGoals("clean install"); projC.setIgnoreUpstremChanges(false); projC.setQuietPeriod(0); projC.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-C.zip"))); buildAndAssertSuccess(projA); buildAndAssertSuccess(projB); buildAndAssertSuccess(projC); projA.setScm(new ExtractResourceSCM(getClass().getResource("maven-dep-test-A-changed.zip"))); buildAndAssertSuccess(projA); waitUntilNoActivityUpTo(90 * 1000); // wait until dependency build trickles down assertEquals( "Expected most recent build of second project to be #2", 2, projB.getLastBuild().getNumber()); assertEquals( "Expected most recent build of third project to be #2", 2, projC.getLastBuild().getNumber()); }
/** * copy from MavenUtil but here we have to ignore localRepo path and setting as thoses paths comes * from the remote node and can not exist in master see * http://issues.jenkins-ci.org/browse/JENKINS-8711 */ private MavenEmbedder createEmbedder(TaskListener listener, AbstractBuild<?, ?> build) throws MavenEmbedderException, IOException, InterruptedException { MavenInstallation m = null; File settingsLoc = null, remoteGlobalSettingsFromConfig = null; String profiles = null; Properties systemProperties = null; String privateRepository = null; FilePath remoteSettingsFromConfig = null; File tmpSettings = File.createTempFile("jenkins", "temp-settings.xml"); try { AbstractProject project = build.getProject(); if (project instanceof MavenModuleSet) { MavenModuleSet mavenModuleSet = ((MavenModuleSet) project); profiles = mavenModuleSet.getProfiles(); systemProperties = mavenModuleSet.getMavenProperties(); // olamy see // we have to take about the settings use for the project // order tru configuration // TODO maybe in goals with -s,--settings last wins but not done in during pom parsing // or -Dmaven.repo.local // if not we must get ~/.m2/settings.xml then $M2_HOME/conf/settings.xml // TODO check if the remoteSettings has a localRepository configured and disabled it String settingsConfigId = mavenModuleSet.getSettingConfigId(); String altSettingsPath = null; if (!StringUtils.isBlank(settingsConfigId)) { Config config = SettingsProviderUtils.findConfig(settingsConfigId, MavenSettingsProvider.class); if (config == null) { listener .getLogger() .println( " your Apache Maven build is setup to use a config with id " + settingsConfigId + " but cannot find the config"); } else { listener .getLogger() .println("redeploy publisher using settings config with name " + config.name); String settingsContent = config.content; if (config.content != null) { remoteSettingsFromConfig = SettingsProviderUtils.copyConfigContentToFilePath(config, build.getWorkspace()); altSettingsPath = remoteSettingsFromConfig.getRemote(); } } } if (mavenModuleSet.getAlternateSettings() != null) { altSettingsPath = mavenModuleSet.getAlternateSettings(); } String globalSettingsConfigId = mavenModuleSet.getGlobalSettingConfigId(); if (!StringUtils.isBlank(globalSettingsConfigId)) { Config config = SettingsProviderUtils.findConfig( globalSettingsConfigId, GlobalMavenSettingsProvider.class); if (config == null) { listener .getLogger() .println( " your Apache Maven build is setup to use a global settings config with id " + globalSettingsConfigId + " but cannot find the config"); } else { listener .getLogger() .println( "redeploy publisher using global settings config with name " + config.name); if (config.content != null) { remoteGlobalSettingsFromConfig = SettingsProviderUtils.copyConfigContentToFile(config); } } } Node buildNode = build.getBuiltOn(); if (buildNode == null) { // assume that build was made on master buildNode = Jenkins.getInstance(); } if (StringUtils.isBlank(altSettingsPath)) { // get userHome from the node where job has been executed String remoteUserHome = build.getWorkspace().act(new GetUserHome()); altSettingsPath = remoteUserHome + "/.m2/settings.xml"; } // we copy this file in the master in a temporary file FilePath filePath = new FilePath(tmpSettings); FilePath remoteSettings = build.getWorkspace().child(altSettingsPath); if (!remoteSettings.exists()) { // JENKINS-9084 we finally use $M2_HOME/conf/settings.xml as maven do String mavenHome = ((MavenModuleSet) project).getMaven().forNode(buildNode, listener).getHome(); String settingsPath = mavenHome + "/conf/settings.xml"; remoteSettings = build.getWorkspace().child(settingsPath); } listener .getLogger() .println( "Maven RedeployPublished use remote " + (buildNode != null ? buildNode.getNodeName() : "local") + " maven settings from : " + remoteSettings.getRemote()); remoteSettings.copyTo(filePath); settingsLoc = tmpSettings; } MavenEmbedderRequest mavenEmbedderRequest = new MavenEmbedderRequest( listener, m != null ? m.getHomeDir() : null, profiles, systemProperties, privateRepository, settingsLoc); if (remoteGlobalSettingsFromConfig != null) { mavenEmbedderRequest.setGlobalSettings(remoteGlobalSettingsFromConfig); } mavenEmbedderRequest.setTransferListener( new ConsoleMavenTransferListener(listener.getLogger())); return MavenUtil.createEmbedder(mavenEmbedderRequest); } finally { if (tmpSettings != null) { tmpSettings.delete(); } if (remoteSettingsFromConfig != null) { remoteSettingsFromConfig.delete(); } FileUtils.deleteQuietly(remoteGlobalSettingsFromConfig); } }
protected Result doRun(BuildListener listener) throws Exception { // pick up a list of reporters to run reporters = getProject().createReporters(); MavenModuleSet mms = getProject().getParent(); if (debug) listener.getLogger().println("Reporters=" + reporters); for (BuildWrapper w : mms.getBuildWrappersList()) { Environment e = w.setUp(MavenBuild.this, launcher, listener); if (e == null) { return Result.FAILURE; } buildEnvironments.add(e); } EnvVars envVars = getEnvironment(listener); // buildEnvironments should be set up first MavenInstallation mvn = getProject().getParent().getMaven(); mvn = mvn.forEnvironment(envVars).forNode(Computer.currentComputer().getNode(), listener); MavenInformation mavenInformation = getModuleRoot().act(new MavenVersionCallable(mvn.getHome())); String mavenVersion = mavenInformation.getVersion(); LOGGER.fine( getFullDisplayName() + " is building with mavenVersion " + mavenVersion + " from file " + mavenInformation.getVersionResourcePath()); boolean maven3orLater = MavenUtil.maven3orLater(mavenVersion); ProcessCache.MavenProcess process = MavenBuild.mavenProcessCache.get( launcher.getChannel(), listener, maven3orLater ? new Maven3ProcessFactory( getParent().getParent(), launcher, envVars, getMavenOpts(listener, envVars), null) : new MavenProcessFactory( getParent().getParent(), launcher, envVars, getMavenOpts(listener, envVars), null)); ArgumentListBuilder margs = new ArgumentListBuilder("-N", "-B"); FilePath localRepo = mms.getLocalRepository().locate(MavenBuild.this); if (localRepo != null) // the workspace must be on this node, so getRemote() is safe. margs.add("-Dmaven.repo.local=" + localRepo.getRemote()); if (mms.getAlternateSettings() != null) { if (IOUtils.isAbsolute(mms.getAlternateSettings())) { margs.add("-s").add(mms.getAlternateSettings()); } else { FilePath mrSettings = getModuleRoot().child(mms.getAlternateSettings()); FilePath wsSettings = getWorkspace().child(mms.getAlternateSettings()); if (!wsSettings.exists() && mrSettings.exists()) wsSettings = mrSettings; margs.add("-s").add(wsSettings.getRemote()); } } margs.add("-f", getModuleRoot().child("pom.xml").getRemote()); margs.addTokenized(getProject().getGoals()); Map<String, String> systemProps = new HashMap<String, String>(envVars); // backward compatibility systemProps.put("hudson.build.number", String.valueOf(getNumber())); if (maven3orLater) { // FIXME here for maven 3 builds listener .getLogger() .println("Building single Maven modules is not implemented for Maven 3, yet!"); return Result.ABORTED; } else { boolean normalExit = false; try { Result r = process.call( new Builder( listener, new ProxyImpl(), getProject(), margs.toList(), systemProps)); normalExit = true; return r; } finally { if (normalExit) process.recycle(); else process.discard(); // tear down in reverse order boolean failed = false; for (int i = buildEnvironments.size() - 1; i >= 0; i--) { if (!buildEnvironments.get(i).tearDown(MavenBuild.this, listener)) { failed = true; } } // WARNING The return in the finally clause will trump any return before if (failed) return Result.FAILURE; } } }
private void rememberModulesToBuildAgainNextTime() { MavenModuleSetBuild moduleSetBuild = getModuleSetBuild(); if (moduleSetBuild == null) { // ModuleSetBuild is gone, for whatever reason JENKINS-9822 return; } if (hasntStartedYet()) { // record modules which have not been build though they should have - i.e. because they // have SCM changes. // see JENKINS-5764 if (moduleSetBuild.getParent().isIncrementalBuild() && moduleSetBuild.getResult() != Result.SUCCESS && moduleSetBuild.getResult() != Result.UNSTABLE) { UnbuiltModuleAction action = moduleSetBuild.getAction(UnbuiltModuleAction.class); if (action == null) { action = new UnbuiltModuleAction(); moduleSetBuild.getActions().add(action); } action.addUnbuiltModule(getParent().getModuleName()); } } else { // mark that this module has been built now, if it has previously been remembered as unbuilt // JENKINS-5764 MavenModuleSetBuild previousParentBuild = moduleSetBuild.getPreviousBuild(); if (previousParentBuild != null) { UnbuiltModuleAction unbuiltModuleAction = previousParentBuild.getAction(UnbuiltModuleAction.class); if (unbuiltModuleAction != null) { unbuiltModuleAction.removeUnbuildModule(getParent().getModuleName()); try { previousParentBuild.save(); } catch (IOException e) { e.printStackTrace(); } } } if (moduleSetBuild.getParent().isIncrementalBuild() && (moduleSetBuild.getResult() != Result.SUCCESS)) { // JENKINS-5121: maybe module needs to be deployed on next build over the deployment // threshold MavenModuleSet mavenModuleSet = moduleSetBuild.getParent(); boolean isDeploying = false; Result deploymentThreshold = Result.SUCCESS; DescribableList<Publisher, Descriptor<Publisher>> publishers = mavenModuleSet.getPublishersList(); for (Publisher publisher : publishers) { if (publisher instanceof RedeployPublisher) { isDeploying = true; deploymentThreshold = ((RedeployPublisher) publisher).getTreshold(); break; } } if (isDeploying && moduleSetBuild.getResult().isWorseThan(deploymentThreshold)) { UnbuiltModuleAction action = moduleSetBuild.getAction(UnbuiltModuleAction.class); if (action == null) { action = new UnbuiltModuleAction(); moduleSetBuild.getActions().add(action); } action.addUnbuiltModule(getParent().getModuleName()); } } } }