mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-14 04:22:16 +00:00
build error message was not captured in the module console output.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@4752 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
ed27cc5d0d
commit
fa2fe21b60
3 files changed
+45
-10
No files matched your search
@@ -230,7 +230,7 @@ public class MavenBuild extends AbstractBuild<MavenModule,MavenBuild> {
|
||||
ProxyImpl2(MavenModuleSetBuild parentBuild,SplittableBuildListener listener) throws FileNotFoundException {
|
||||
this.parentBuild = parentBuild;
|
||||
this.listener = listener;
|
||||
log = new BufferedOutputStream(new FileOutputStream(getLogFile()));
|
||||
log = new FileOutputStream(getLogFile()); // no buffering so that AJAX clients can see the log live
|
||||
}
|
||||
|
||||
public void start() {
|
||||
@@ -257,19 +257,28 @@ public class MavenBuild extends AbstractBuild<MavenModule,MavenBuild> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the build for which this proxy is created.
|
||||
*/
|
||||
public MavenBuild owner() {
|
||||
return MavenBuild.this;
|
||||
public void appendLastLog() {
|
||||
try {
|
||||
listener.setSideOutputStream(log);
|
||||
listener.setSideOutputStream(null);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the build as aborted. This method is used when the aggregated build
|
||||
* failed before it didn't even get to this module.
|
||||
* Performs final clean up. Invoked after the entire aggregator build is completed.
|
||||
*/
|
||||
protected void abortIfNotStarted() {
|
||||
protected void close() {
|
||||
try {
|
||||
log.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(hasntStartedYet()) {
|
||||
// Mark the build as aborted. This method is used when the aggregated build
|
||||
// failed before it didn't even get to this module.
|
||||
run(new Runner() {
|
||||
public Result run(BuildListener listener) {
|
||||
listener.getLogger().println("Build failed before it gets to this module");
|
||||
@@ -282,6 +291,13 @@ public class MavenBuild extends AbstractBuild<MavenModule,MavenBuild> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the build for which this proxy is created.
|
||||
*/
|
||||
public MavenBuild owner() {
|
||||
return MavenBuild.this;
|
||||
}
|
||||
|
||||
private Object writeReplace() {
|
||||
return Channel.current().export(MavenBuildProxy2.class,this);
|
||||
}
|
||||
|
||||
@@ -17,4 +17,12 @@ interface MavenBuildProxy2 extends MavenBuildProxy {
|
||||
* Notifies that the build has left a module.
|
||||
*/
|
||||
void end();
|
||||
|
||||
/**
|
||||
* Maven produces additional error message after the module build is done.
|
||||
* So to catch those messages, invoke this method on the last module that was built
|
||||
* after all the Maven processing is done, to append last messages to the console
|
||||
* output of the module.
|
||||
*/
|
||||
void appendLastLog();
|
||||
}
|
||||
@@ -308,7 +308,7 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
|
||||
slistener,proxies,project.sortedActiveModules,margs.toList(),envVars));
|
||||
} finally {
|
||||
for (ProxyImpl2 p : proxies.values())
|
||||
p.abortIfNotStarted();
|
||||
p.close();
|
||||
process.discard();
|
||||
}
|
||||
}
|
||||
@@ -356,6 +356,7 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
|
||||
private final Map<ModuleName,List<ExecutedMojo>> executedMojos = new HashMap<ModuleName,List<ExecutedMojo>>();
|
||||
private long mojoStartTime;
|
||||
|
||||
private MavenBuildProxy2 lastProxy;
|
||||
|
||||
public Builder(BuildListener listener,Map<ModuleName,? extends MavenBuildProxy2> proxies, Collection<MavenModule> modules, List<String> goals, Map<String,String> systemProps) {
|
||||
super(listener,goals,systemProps);
|
||||
@@ -365,6 +366,15 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
|
||||
reporters.put(m.getModuleName(),m.createReporters());
|
||||
}
|
||||
|
||||
public Result call() throws IOException {
|
||||
try {
|
||||
return super.call();
|
||||
} finally {
|
||||
if(lastProxy!=null)
|
||||
lastProxy.appendLastLog();
|
||||
}
|
||||
}
|
||||
|
||||
void preBuild(MavenSession session, ReactorManager rm, EventDispatcher dispatcher) throws BuildFailureException, LifecycleExecutionException, IOException, InterruptedException {
|
||||
// TODO
|
||||
}
|
||||
@@ -392,6 +402,7 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
|
||||
proxy.setExecutedMojos(executedMojos.get(name));
|
||||
listener.getLogger().flush(); // make sure the data until here are all written
|
||||
proxy.end();
|
||||
lastProxy = proxy;
|
||||
}
|
||||
|
||||
void preExecute(MavenProject project, MojoInfo mojoInfo) throws IOException, InterruptedException, hudson.maven.agent.AbortException {
|
||||
|
||||
Reference in new issue
Block a user