Skip to content

Commit

Permalink
Replace the default node launcher (#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
swamygoud18 authored Sep 27, 2023
1 parent c1345bf commit df4b45d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/main/java/org/jfrog/hudson/pipeline/common/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,20 @@ public String call() throws IOException {
/**
* Launch a process. Throw a RuntimeException in case of an error.
*
* @param taskName - The task name - Maven, Gradle, npm, etc.
* @param launcher - The launcher
* @param args - The arguments
* @param env - Task environment
* @param listener - Task listener
* @param ws - The workspace
* @param taskName - The task name - Maven, Gradle, npm, etc.
* @param nodeLauncher - The default launcher from the node
* @param args - The arguments
* @param env - Task environment
* @param listener - Task listener
* @param ws - The workspace
*/
public static void launch(String taskName, Launcher launcher, ArgumentListBuilder args, EnvVars env, TaskListener listener, FilePath ws) {
public static void launch(String taskName, Launcher nodeLauncher, ArgumentListBuilder args, EnvVars env, TaskListener listener, FilePath ws) {
try {
// Creating default remote launcher irrespective of any type of node.
// Using the default launcher from the node is causing intermittent hangs, depending on the node type and the plugin using to launch that node.
Node node = ActionableHelper.getNode(nodeLauncher);
Launcher launcher = node.createLauncher(listener);

int exitValue = launcher.launch().cmds(args).envs(env).stdout(listener).stderr(listener.getLogger()).pwd(ws).join();
if (exitValue != 0) {
throw new RuntimeException(taskName + " build failed with exit code " + exitValue);
Expand Down Expand Up @@ -418,7 +423,7 @@ public static void addParentBuildProps(ArrayListMultimap<String, String> propert
properties.put(BuildInfoFields.BUILD_PARENT_NAME, ExtractorUtils.sanitizeBuildName(buildName));
Integer buildNumber = ActionableHelper.getUpstreamBuild(build);
if (buildNumber != null) {
properties.put(BuildInfoFields.BUILD_PARENT_NUMBER, buildNumber+ "");
properties.put(BuildInfoFields.BUILD_PARENT_NUMBER, buildNumber + "");
}
}

Expand Down

0 comments on commit df4b45d

Please sign in to comment.