-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathExecuteKatalonStudioHelper.java
More file actions
68 lines (61 loc) · 2.44 KB
/
ExecuteKatalonStudioHelper.java
File metadata and controls
68 lines (61 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.katalon.jenkins.plugin.helper;
import com.google.common.base.Throwables;
import com.katalon.utils.KatalonUtils;
import com.katalon.utils.Logger;
import hudson.EnvVars;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.TaskListener;
import hudson.remoting.VirtualChannel;
import jenkins.security.MasterToSlaveCallable;
import java.util.HashMap;
import java.util.Map;
public class ExecuteKatalonStudioHelper {
public static boolean executeKatalon(
FilePath workspace,
EnvVars buildEnvironment,
Launcher launcher,
TaskListener taskListener,
String version,
String location,
String executeArgs,
String x11Display,
String xvfbConfiguration) {
Logger logger = new JenkinsLogger(taskListener);
try {
VirtualChannel channel = launcher.getChannel();
if (channel == null) {
throw new Exception("Channel not found!");
}
return channel.call(new MasterToSlaveCallable<Boolean, Exception>() {
@Override
public Boolean call() throws Exception {
Logger logger = new JenkinsLogger(taskListener);
if (workspace != null) {
String workspaceLocation = workspace.getRemote();
if (workspaceLocation != null) {
Map<String, String> environmentVariables = new HashMap<>();
environmentVariables.putAll(System.getenv());
buildEnvironment.entrySet()
.forEach(entry -> environmentVariables.put(entry.getKey(), entry.getValue()));
return KatalonUtils.executeKatalon(
logger,
version,
location,
workspaceLocation,
executeArgs,
x11Display,
xvfbConfiguration,
environmentVariables);
}
}
return true;
}
});
} catch (Exception e) {
String stackTrace = Throwables.getStackTraceAsString(e);
logger.info(stackTrace);
return false;
}
}
}