mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-22 00:05:31 +00:00
prevent some CNFE during tests with call token macro with reflection
This commit is contained in:
1 parent
3bd3ff9b57
commit
c2cd2d11f2
2 files changed
+19
-13
No files matched your search
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
|
||||
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Olivier Lamy
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -45,6 +45,7 @@ import hudson.tasks.BuildWrapper;
|
||||
import hudson.tasks.Maven.MavenInstallation;
|
||||
import hudson.util.ArgumentListBuilder;
|
||||
import hudson.util.IOUtils;
|
||||
import hudson.util.ReflectionUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -52,6 +53,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
@@ -66,8 +68,6 @@ import org.apache.maven.execution.ReactorManager;
|
||||
import org.apache.maven.lifecycle.LifecycleExecutionException;
|
||||
import org.apache.maven.monitor.event.EventDispatcher;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.jenkinsci.plugins.tokenmacro.MacroEvaluationException;
|
||||
import org.jenkinsci.plugins.tokenmacro.TokenMacro;
|
||||
import org.kohsuke.stapler.Ancestor;
|
||||
import org.kohsuke.stapler.Stapler;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
@@ -682,9 +682,13 @@ public class MavenBuild extends AbstractMavenBuild<MavenModule,MavenBuild> {
|
||||
String opts = mms.getMavenOpts();
|
||||
if (opts == null ) return null;
|
||||
try {
|
||||
opts = TokenMacro.expand(this, listener, opts);
|
||||
} catch (MacroEvaluationException e) {
|
||||
listener.error( "Ignore MacroEvaluationException " + e.getMessage() );
|
||||
Class<?> clazz = Class.forName( "org.jenkinsci.plugins.tokenmacro.MacroEvaluationException" );
|
||||
Method expandMethod =
|
||||
ReflectionUtils.findMethod(clazz, "expand", new Class[]{ this.getClass(), listener.getClass(), String.class} );
|
||||
opts = (String) expandMethod.invoke( null, this, listener, opts );
|
||||
//opts = TokenMacro.expand(this, listener, opts);
|
||||
//} catch (MacroEvaluationException e) {
|
||||
// listener.error( "Ignore MacroEvaluationException " + e.getMessage() );
|
||||
}
|
||||
catch(Exception tokenException) {
|
||||
listener.error("Ignore Problem expanding maven opts macros " + tokenException.getMessage());
|
||||
|
||||
@@ -60,6 +60,7 @@ import hudson.tasks.Maven.MavenInstallation;
|
||||
import hudson.util.ArgumentListBuilder;
|
||||
import hudson.util.IOUtils;
|
||||
import hudson.util.MaskingClassLoader;
|
||||
import hudson.util.ReflectionUtils;
|
||||
import hudson.util.StreamTaskListener;
|
||||
|
||||
import java.io.File;
|
||||
@@ -67,6 +68,7 @@ import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.PrintStream;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -92,11 +94,7 @@ import org.apache.maven.model.building.ModelBuildingRequest;
|
||||
import org.apache.maven.monitor.event.EventDispatcher;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.configuration.DefaultPlexusConfiguration;
|
||||
import org.codehaus.plexus.util.PathTool;
|
||||
import org.jenkinsci.plugins.tokenmacro.MacroEvaluationException;
|
||||
import org.jenkinsci.plugins.tokenmacro.TokenMacro;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
import org.sonatype.aether.transfer.TransferCancelledException;
|
||||
@@ -528,9 +526,13 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
String opts = project.getMavenOpts();
|
||||
if (opts == null ) return null;
|
||||
try {
|
||||
opts = TokenMacro.expand(this, listener, opts);
|
||||
} catch (MacroEvaluationException e) {
|
||||
listener.error( "Ignore MacroEvaluationException " + e.getMessage() );
|
||||
Class<?> clazz = Class.forName( "org.jenkinsci.plugins.tokenmacro.MacroEvaluationException" );
|
||||
Method expandMethod =
|
||||
ReflectionUtils.findMethod(clazz, "expand", new Class[]{ this.getClass(), listener.getClass(), String.class} );
|
||||
opts = (String) expandMethod.invoke( null, this, listener, opts );
|
||||
//opts = TokenMacro.expand(this, listener, opts);
|
||||
//} catch (MacroEvaluationException e) {
|
||||
// listener.error( "Ignore MacroEvaluationException " + e.getMessage() );
|
||||
}
|
||||
catch(Exception tokenException) {
|
||||
listener.error("Ignore Problem expanding maven opts macros " + tokenException.getMessage());
|
||||
|
||||
Reference in new issue
Block a user