diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java index 95e0d6551e..e45b9b876e 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java @@ -38,12 +38,11 @@ import hudson.maven.settings.MavenSettingsProvider; import hudson.model.AbstractProject; import hudson.model.Action; import hudson.model.BuildableItemWithBuildWrappers; +import hudson.tasks.Builder; import hudson.model.DependencyGraph; import hudson.model.Descriptor; import hudson.model.Descriptor.FormException; import hudson.model.Executor; -import hudson.model.TaskListener; -import jenkins.model.Jenkins; import hudson.model.Item; import hudson.model.ItemGroup; import hudson.model.Job; @@ -52,6 +51,7 @@ import hudson.model.Queue.Task; import hudson.model.ResourceActivity; import hudson.model.SCMedItem; import hudson.model.Saveable; +import hudson.model.TaskListener; import hudson.model.TopLevelItem; import hudson.search.CollectionSearchIndex; import hudson.search.SearchIndexBuilder; @@ -87,6 +87,7 @@ import java.util.Stack; import javax.servlet.ServletException; +import jenkins.model.Jenkins; import net.sf.json.JSONObject; import org.apache.commons.lang.math.NumberUtils; @@ -111,6 +112,8 @@ import org.kohsuke.stapler.export.Exported; * @author Kohsuke Kawaguchi */ public class MavenModuleSet extends AbstractMavenProject implements TopLevelItem, ItemGroup, SCMedItem, Saveable, BuildableItemWithBuildWrappers { + + /** * All {@link MavenModule}s, keyed by their {@link MavenModule#getModuleName()} module name}s. */ @@ -254,6 +257,18 @@ public class MavenModuleSet extends AbstractMavenProject> buildWrappers = new DescribableList>(this); + /** + * List of active {@link Builder}s configured for this project. + */ + private DescribableList> prebuilders = + new DescribableList>(this); + + private DescribableList> postbuilders = + new DescribableList>(this); + + private String runPostStepsIfResult; + + /** * @deprecated * Use {@link #MavenModuleSet(ItemGroup, String)} @@ -266,6 +281,21 @@ public class MavenModuleSet extends AbstractMavenProject getPrebuilders() { + return prebuilders.toList(); + } + + public List getPostbuilders() { + return postbuilders.toList(); + } + + /** + * @return Returns the runIfResult value. + */ + public String getRunPostStepsIfResult() { + return runPostStepsIfResult; + } + public String getUrlChildPrefix() { // seemingly redundant "./" is used to make sure that ':' is not interpreted as the scheme identifier return "."; @@ -595,16 +625,27 @@ public class MavenModuleSet extends AbstractMavenProject>(this); + } reporters.setOwner(this); - if(publishers==null) + if(publishers==null){ publishers = new DescribableList>(this); + } publishers.setOwner(this); - if(buildWrappers==null) + if(buildWrappers==null){ buildWrappers = new DescribableList>(this); + } buildWrappers.setOwner(this); - + if(prebuilders==null){ + prebuilders = new DescribableList>(this); + } + prebuilders.setOwner(this); + if(postbuilders==null){ + postbuilders = new DescribableList>(this); + } + postbuilders.setOwner(this); + updateTransientActions(); } @@ -660,6 +701,8 @@ public class MavenModuleSet extends AbstractMavenProject { + /** * {@link MavenReporter}s that will contribute project actions. * Can be null if there's none. @@ -555,12 +559,13 @@ public class MavenModuleSetBuild extends AbstractMavenBuild proxies; protected Result doRun(final BuildListener listener) throws Exception { - PrintStream logger = listener.getLogger(); - Result r = null; + + Result r = null; + PrintStream logger = listener.getLogger(); FilePath remoteSettings = null, remoteGlobalSettings = null; try { - + EnvVars envVars = getEnvironment(listener); MavenInstallation mvn = project.getMaven(); if(mvn==null) @@ -586,6 +591,17 @@ public class MavenModuleSetBuild extends AbstractMavenBuild wrappers = new ArrayList(); for (BuildWrapper w : project.getBuildWrappersList()) wrappers.add(w); @@ -601,8 +617,10 @@ public class MavenModuleSetBuild extends AbstractMavenBuild steps) throws IOException, InterruptedException { + for( BuildStep bs : steps ){ + if(!perform(bs,listener)) { + LOGGER.fine(MessageFormat.format("{1} failed", bs)); + return false; + } + } + return true; + } + + private boolean shouldPostStepsRun(Result buildResult, String runIfResult) { + // If runIfResult is null, set it to "allCases". + if (runIfResult == null) { + runIfResult = "allCases"; + } + // If runIfResult is "allCases", we're running regardless. + if (runIfResult.equals("allCases")) { + return true; + } + else { + // Otherwise, we're going to need to compare against the build result. + + if (runIfResult.equals("success")) { + return ((buildResult==null) || (buildResult.isBetterOrEqualTo(Result.SUCCESS))); + } + else if (runIfResult.equals("unstable")) { + return ((buildResult==null) || (buildResult.isBetterOrEqualTo(Result.UNSTABLE))); + } + } + + // If we get down here, something weird's going on. Return false. + return false; + } /** * Returns the modules which have not been build since the last successful aggregator build * though they should be because they had SCM changes. diff --git a/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/configure-entries.jelly b/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/configure-entries.jelly index 324e06b7ef..17371b89ca 100644 --- a/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/configure-entries.jelly +++ b/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/configure-entries.jelly @@ -38,6 +38,15 @@ THE SOFTWARE. + + + + + + @@ -129,6 +138,39 @@ THE SOFTWARE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/configure-entries.properties b/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/configure-entries.properties index d91e31e66c..a0a2620a63 100644 --- a/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/configure-entries.properties +++ b/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/configure-entries.properties @@ -21,4 +21,8 @@ # THE SOFTWARE. Maven\ Version.error.1=Jenkins needs to know where your Maven2 is installed. -Maven\ Version.error.2=Please do so from the system configuration. \ No newline at end of file +Maven\ Version.error.2=Please do so from the system configuration. +criteriaDescription=Should the post-build steps run only for successful builds, etc. +runIfStable=Run only if build succeeds +runIfSuccessful=Run only if build succeeds or is unstable +runAlways=Run regardless of build result \ No newline at end of file diff --git a/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/configure-entries_fr.properties b/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/configure-entries_fr.properties index bb43380281..64366fb6e7 100644 --- a/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/configure-entries_fr.properties +++ b/maven-plugin/src/main/resources/hudson/maven/MavenModuleSet/configure-entries_fr.properties @@ -40,3 +40,8 @@ Resolve\ Dependencies\ during\ Pom\ parsing=Effectue la r\u00e9solution de d\u00 Process\ Plugins\ during\ Pom\ parsing=Analyse les plugins pendant la lecture du POM Maven\ Validation\ Level=Niveau de validation du POM Maven Goals=Goals +Add\ post-build\ step=Ajouter une \u00E9tape pr\u00E9-build +Add\ pre-build\ step=Ajouter une \u00E9tape pr\u00E9-build +Post-Build\ Run\ Criteria=Crit\u00E8re pour ex\u00E9cuter le post-build +Steps\ to\ run\ after\ mvn\ build=\u00C9tapes \u00E0 lancer apr\u00E8s le build maven +Steps\ to\ run\ before\ mvn\ build=\u00C9tapes \u00E0 lancer avant le build maven \ No newline at end of file