Skip to content
Permalink
Browse files

[JENKINS-37077] Check classpath before executing task

  • Loading branch information...
rachaumi
rachaumi committed Jun 23, 2017
1 parent 307c57f commit 424a0554749a05fcf8cb100b5dd24447587afba2
@@ -168,14 +168,8 @@ private static void processJavaLauncher(WebLogicDeployerParameters parameter, Ar
parameter.getListener().error("[WeblogicDeploymentPlugin] - Classpath is not set. Please configure correctly the plugin.");
throw new RunnerAbortedException();
}
String remotingJar = StringUtils.EMPTY;
// On recalcule le classpath à partir du workspace si on est en remote
if(! StringUtils.EMPTY.equalsIgnoreCase(parameter.getBuild().getBuiltOnStr())){
remotingJar = DeployerClassPathUtils.formatClasspath(parameter.getClasspath(), parameter.getBuild(), parameter.getListener());
} else {
remotingJar = parameter.getClasspath();
}

String remotingJar = DeployerClassPathUtils.formatAndCheckClasspath(parameter.getClasspath(), parameter.getBuild(), parameter.getListener());
args.add(remotingJar);
args.add(WebLogicDeploymentPluginConstantes.WL_WEBLOGIC_API_DEPLOYER_MAIN_CLASS);

@@ -4,6 +4,7 @@
package org.jenkinsci.plugins.deploy.weblogic.util;

import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.deploy.weblogic.properties.WebLogicDeploymentPluginConstantes;

import hudson.FilePath;
@@ -44,7 +45,17 @@ public static String getDefaultPathToWebLogicJar() {
* @param build
* @return
*/
public static String formatClasspath(final String classpath, AbstractBuild<?, ?> build, BuildListener listener){
public static String formatAndCheckClasspath(final String classpath, AbstractBuild<?, ?> build, BuildListener listener){
// execution sur un node : il faut reformatter le cp + verifier la presence
if(! StringUtils.EMPTY.equalsIgnoreCase(build.getBuiltOnStr())){
return formatAndCheckClasspathForNode(classpath, build, listener);
}
// si c'est sur le master pour l'instant on ne fait que le check
checkClasspath(classpath, build, listener);
return classpath;
}

private static String formatAndCheckClasspathForNode(final String classpath, AbstractBuild<?, ?> build, BuildListener listener){
StringBuilder fromWorkspaceClassPath = new StringBuilder();
try {
VirtualChannel channel = build.getWorkspace().getChannel();
@@ -70,6 +81,24 @@ public static String formatClasspath(final String classpath, AbstractBuild<?, ?>
return fromWorkspaceClassPath.toString();
}

public static void checkClasspath(final String classpath, AbstractBuild<?, ?> build, BuildListener listener){
try {
for(String path : classpath.split(File.pathSeparator)){
FilePath srcFile = new FilePath(new File(path));
if(! srcFile.exists()){
listener.error("[WeblogicDeploymentPlugin] - The following library '"+srcFile.getName()+"' declared on classpath is missing");
throw new RunnerAbortedException();
}
}
} catch (IOException e) {
listener.error("[WeblogicDeploymentPlugin] - Unable to check classpath for invocation.", e);
throw new RunnerAbortedException();
} catch (InterruptedException e) {
listener.error("[WeblogicDeploymentPlugin] - Unable to check classpath for invocation.", e);
throw new RunnerAbortedException();
}
}

/**
* Checks if the remote path is Unix.
* Recuperer de la classe FilePath car methode non acessible en dehors du package

0 comments on commit 424a055

Please sign in to comment.
You can’t perform that action at this time.