mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 05:22:22 +00:00
integrate m2extra-steps into maven-plugin
This commit is contained in:
1 parent
9a48907ab0
commit
cd968ce2d8
5 files changed
+181
-13
No files matched your search
@@ -47,7 +47,6 @@ import hudson.model.Computer;
|
||||
import hudson.model.Environment;
|
||||
import hudson.model.Executor;
|
||||
import hudson.model.Fingerprint;
|
||||
import jenkins.model.Jenkins;
|
||||
import hudson.model.ParameterDefinition;
|
||||
import hudson.model.ParametersAction;
|
||||
import hudson.model.ParametersDefinitionProperty;
|
||||
@@ -58,6 +57,7 @@ import hudson.model.TaskListener;
|
||||
import hudson.remoting.Channel;
|
||||
import hudson.remoting.VirtualChannel;
|
||||
import hudson.scm.ChangeLogSet;
|
||||
import hudson.tasks.BuildStep;
|
||||
import hudson.tasks.BuildWrapper;
|
||||
import hudson.tasks.MailSender;
|
||||
import hudson.tasks.Maven.MavenInstallation;
|
||||
@@ -71,6 +71,7 @@ import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.PrintStream;
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -85,6 +86,8 @@ import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import jenkins.model.Jenkins;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.BuildFailureException;
|
||||
@@ -123,6 +126,7 @@ import org.sonatype.aether.transfer.TransferListener;
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,MavenModuleSetBuild> {
|
||||
|
||||
/**
|
||||
* {@link MavenReporter}s that will contribute project actions.
|
||||
* Can be null if there's none.
|
||||
@@ -555,12 +559,13 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
private Map<ModuleName,MavenBuild.ProxyImpl2> 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<MavenModuleSet,Maven
|
||||
} else {
|
||||
// do builds here
|
||||
try {
|
||||
// run pre build steps
|
||||
if(!preBuild(listener,project.getPrebuilders())){
|
||||
r = FAILURE;
|
||||
return r;
|
||||
}
|
||||
if(!build(listener,project.getPrebuilders())){
|
||||
r = FAILURE;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
List<BuildWrapper> wrappers = new ArrayList<BuildWrapper>();
|
||||
for (BuildWrapper w : project.getBuildWrappersList())
|
||||
wrappers.add(w);
|
||||
@@ -601,8 +617,10 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
e.buildEnvVars(envVars); // #3502: too late for getEnvironment to do this
|
||||
}
|
||||
|
||||
if(!preBuild(listener, project.getPublishers()))
|
||||
return Result.FAILURE;
|
||||
if(!preBuild(listener, project.getPublishers())){
|
||||
r = FAILURE;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
String settingsConfigId = project.getSettingConfigId();
|
||||
@@ -779,6 +797,20 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
r = Executor.currentExecutor().abortResult();
|
||||
throw e;
|
||||
} finally {
|
||||
// only run post build steps if requested...
|
||||
if(shouldPostStepsRun(r, project.getRunPostStepsIfResult())){
|
||||
boolean proceedPostSteps = true;
|
||||
if(!preBuild(listener,project.getPostbuilders())){
|
||||
r = FAILURE;
|
||||
proceedPostSteps = false;
|
||||
}
|
||||
if(proceedPostSteps){
|
||||
if(!build(listener,project.getPostbuilders())){
|
||||
r = FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (r != null) {
|
||||
setResult(r);
|
||||
}
|
||||
@@ -794,6 +826,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return r;
|
||||
} catch (AbortException e) {
|
||||
if(e.getMessage()!=null)
|
||||
@@ -830,6 +863,40 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean build(BuildListener listener, Collection<hudson.tasks.Builder> 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.
|
||||
|
||||
Reference in new issue
Block a user