Skip to content

Commit

Permalink
LWW-2668 Resolve merge conflict between fork repos (leapwork#61)
Browse files Browse the repository at this point in the history
* Automatic plugin release (#1)

* Automatic release prerequisites

* Updating for CD, automatic release (#6)

- Updating cd.yml file (from the master branch, not yet on the main branch)
- adding yaml file (from the master branch, not yet on the main branch)
- Do not ignore .mvn dir contents (already in another pull request)
- Use parent pom 4.24 (would be best if dependabot were enabled on this repo)
- Use changelist property for version (incrementals) (already in another pull request)
- Use scmTag symbol, not explicit tag (already in another pull request)
- Use most recent plugin bom release (would be best if dependabot were enabled on this repo)
- Use most recent JQuery plugin release (see the comment that explains why you should use a different JQuery library)
- Remove unused dependency, do not include jsr305 jar in hpi (remove jsr305 jar from the hpi because it is not needed)

* chore: use jenkins infra maven cd reusable workflow (#23)

Signed-off-by: Joseph Petersen <[email protected]>

Signed-off-by: Joseph Petersen <[email protected]>

* Update Jenkinsfile syntax (#24)

* Increased Read/Request timeout to 180 seconds (#25)

Co-authored-by: Sachin Tomar <[email protected]>

* Revert "Increased Read/Request timeout to 180 seconds (#25)" (#26)

This reverts commit 3937e68.

Co-authored-by: Sachin Tomar <[email protected]>

* enhancement : Increased Read/Request timeout to 180 seconds (#27)

* Increased Read/Request timeout to 180 seconds (leapwork#53)

Co-authored-by: Sachin Tomar <[email protected]>

* Revert "Increased Read/Request timeout to 180 seconds (leapwork#53)" (leapwork#54)

This reverts commit 2be482a.

Co-authored-by: Sachin Tomar <[email protected]>

* enhancement :  Increased Read/Request timeout to 180 seconds (leapwork#55)

Co-authored-by: Sachin Tomar <[email protected]>

---------

Co-authored-by: Sachin Tomar <[email protected]>

* enhancement : Increased Read/Request timeout to 180 seconds - 2 (#28)

* Increased Read/Request timeout to 180 seconds (leapwork#53)

Co-authored-by: Sachin Tomar <[email protected]>

* Revert "Increased Read/Request timeout to 180 seconds (leapwork#53)" (leapwork#54)

This reverts commit 2be482a.

Co-authored-by: Sachin Tomar <[email protected]>

* enhancement :  Increased Read/Request timeout to 180 seconds (leapwork#55)

Co-authored-by: Sachin Tomar <[email protected]>

* enhancement : Made http timeout configurable for all API Requests (default 300 seconds) (leapwork#56)

* enhancement : Increased http timeout to 5 min

* Made http timeout configurable in all API Requests

---------

Co-authored-by: Sachin Tomar <[email protected]>

* Upgraded plugin version to 4.0.9 (leapwork#57)

Co-authored-by: Sachin Tomar <[email protected]>

* Revert configurable timeout (leapwork#58)

* Revert "Upgraded plugin version to 4.0.9 (leapwork#57)"

This reverts commit 77c3605.

* Revert "enhancement : Made http timeout configurable for all API Requests (default 300 seconds) (leapwork#56)"

This reverts commit d69096e.

---------

Co-authored-by: Sachin Tomar <[email protected]>

---------

Co-authored-by: Sachin Tomar <[email protected]>

* enhancement : Made http timeout configurable for all API Requests - 2 (#29)

Co-authored-by: Sachin Tomar <[email protected]>

* enhancement : Configuration Changes related to java 11 (#31)

* Configuration Changes related to java 11

* version change

* enhacement : Jenkins Plugin Upgrade to 2.440.1 (#32)

* Configuration Changes related to java 11

* version change

* Jenkins Plugin Upgrade

* Re Run Test cases

* Reverted extra space

* enhacement :  Resolve conflicts and aligned Jenkins sci branch with the latest changes (#34)

* Increased Read/Request timeout to 180 seconds (leapwork#53)

Co-authored-by: Sachin Tomar <[email protected]>

* Revert "Increased Read/Request timeout to 180 seconds (leapwork#53)" (leapwork#54)

This reverts commit 2be482a.

Co-authored-by: Sachin Tomar <[email protected]>

* enhancement :  Increased Read/Request timeout to 180 seconds (leapwork#55)

Co-authored-by: Sachin Tomar <[email protected]>

* enhancement : Made http timeout configurable for all API Requests (default 300 seconds) (leapwork#56)

* enhancement : Increased http timeout to 5 min

* Made http timeout configurable in all API Requests

---------

Co-authored-by: Sachin Tomar <[email protected]>

* Upgraded plugin version to 4.0.9 (leapwork#57)

Co-authored-by: Sachin Tomar <[email protected]>

* Revert configurable timeout (leapwork#58)

* Revert "Upgraded plugin version to 4.0.9 (leapwork#57)"

This reverts commit 77c3605.

* Revert "enhancement : Made http timeout configurable for all API Requests (default 300 seconds) (leapwork#56)"

This reverts commit d69096e.

---------

Co-authored-by: Sachin Tomar <[email protected]>

* Sync Leapwork from JenkinsCI (leapwork#59)

* Automatic plugin release (#1)

* Automatic release prerequisites

* Updating for CD, automatic release (#6)

- Updating cd.yml file (from the master branch, not yet on the main branch)
- adding yaml file (from the master branch, not yet on the main branch)
- Do not ignore .mvn dir contents (already in another pull request)
- Use parent pom 4.24 (would be best if dependabot were enabled on this repo)
- Use changelist property for version (incrementals) (already in another pull request)
- Use scmTag symbol, not explicit tag (already in another pull request)
- Use most recent plugin bom release (would be best if dependabot were enabled on this repo)
- Use most recent JQuery plugin release (see the comment that explains why you should use a different JQuery library)
- Remove unused dependency, do not include jsr305 jar in hpi (remove jsr305 jar from the hpi because it is not needed)

* chore: use jenkins infra maven cd reusable workflow (#23)

Signed-off-by: Joseph Petersen <[email protected]>

Signed-off-by: Joseph Petersen <[email protected]>

* Update Jenkinsfile syntax (#24)

* Increased Read/Request timeout to 180 seconds (#25)

Co-authored-by: Sachin Tomar <[email protected]>

* Revert "Increased Read/Request timeout to 180 seconds (#25)" (#26)

This reverts commit 3937e68.

Co-authored-by: Sachin Tomar <[email protected]>

* enhancement : Increased Read/Request timeout to 180 seconds (#27)

* Increased Read/Request timeout to 180 seconds (leapwork#53)

Co-authored-by: Sachin Tomar <[email protected]>

* Revert "Increased Read/Request timeout to 180 seconds (leapwork#53)" (leapwork#54)

This reverts commit 2be482a.

Co-authored-by: Sachin Tomar <[email protected]>

* enhancement :  Increased Read/Request timeout to 180 seconds (leapwork#55)

Co-authored-by: Sachin Tomar <[email protected]>

---------

Co-authored-by: Sachin Tomar <[email protected]>

* enhancement : Increased Read/Request timeout to 180 seconds - 2 (#28)

* Increased Read/Request timeout to 180 seconds (leapwork#53)

Co-authored-by: Sachin Tomar <[email protected]>

* Revert "Increased Read/Request timeout to 180 seconds (leapwork#53)" (leapwork#54)

This reverts commit 2be482a.

Co-authored-by: Sachin Tomar <[email protected]>

* enhancement :  Increased Read/Request timeout to 180 seconds (leapwork#55)

Co-authored-by: Sachin Tomar <[email protected]>

* enhancement : Made http timeout configurable for all API Requests (default 300 seconds) (leapwork#56)

* enhancement : Increased http timeout to 5 min

* Made http timeout configurable in all API Requests

---------

Co-authored-by: Sachin Tomar <[email protected]>

* Upgraded plugin version to 4.0.9 (leapwork#57)

Co-authored-by: Sachin Tomar <[email protected]>

* Revert configurable timeout (leapwork#58)

* Revert "Upgraded plugin version to 4.0.9 (leapwork#57)"

This reverts commit 77c3605.

* Revert "enhancement : Made http timeout configurable for all API Requests (default 300 seconds) (leapwork#56)"

This reverts commit d69096e.

---------

Co-authored-by: Sachin Tomar <[email protected]>

---------

Co-authored-by: Sachin Tomar <[email protected]>

---------

Signed-off-by: Joseph Petersen <[email protected]>
Co-authored-by: BirSikanderMahajan <[email protected]>
Co-authored-by: Anton Liakhovich <[email protected]>
Co-authored-by: Joseph Petersen <[email protected]>
Co-authored-by: Alexander Brandes <[email protected]>
Co-authored-by: Sachin Tomar <[email protected]>

---------

Signed-off-by: Joseph Petersen <[email protected]>
Co-authored-by: Sachin Tomar <[email protected]>
Co-authored-by: BirSikanderMahajan <[email protected]>
Co-authored-by: Anton Liakhovich <[email protected]>
Co-authored-by: Joseph Petersen <[email protected]>
Co-authored-by: Alexander Brandes <[email protected]>
Co-authored-by: Sachin Tomar <[email protected]>

* [LWW-1805] : Upgraded Jquery to Jquery 3 (#37)

Co-authored-by: Sachin Tomar <[email protected]>

* Changes related to -rc in jenkins release build number (#42)

---------

Signed-off-by: Joseph Petersen <[email protected]>
Co-authored-by: BirSikanderMahajan <[email protected]>
Co-authored-by: Anton Liakhovich <[email protected]>
Co-authored-by: Joseph Petersen <[email protected]>
Co-authored-by: Alexander Brandes <[email protected]>
Co-authored-by: Sachin Tomar <[email protected]>
Co-authored-by: Munishh992 <[email protected]>
Co-authored-by: Sachin Tomar <[email protected]>
  • Loading branch information
8 people authored Aug 23, 2024
1 parent 85b3a77 commit c457cf3
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 202 deletions.
1 change: 1 addition & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
-Pconsume-incrementals
-Pmight-produce-incrementals
-Dchangelist.format=-%d.v%s
5 changes: 4 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
See the documentation for more options:
https://github.com/jenkins-infra/pipeline-library/
*/
buildPlugin(useContainerAgent: true)
buildPlugin(useContainerAgent: true,configurations: [
[platform: 'linux', jdk: 11],
[platform: 'windows', jdk: 11],
])
86 changes: 24 additions & 62 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.24</version>
<version>4.80</version>
<relativePath />
</parent>
<groupId>io.jenkins.plugins</groupId>
<artifactId>leapwork</artifactId>
<version>${revision}${changelist}</version>
<packaging>hpi</packaging>
<properties>
<revision>4.0.8</revision>
<revision>4.0.12</revision>
<changelist>-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/leapwork-plugin</gitHubRepo>
<changelist>-SNAPSHOT</changelist>
<!-- Baseline Jenkins version you use to build the plugin. Users must have
this version or newer to run. -->
<jenkins.version>2.277.1</jenkins.version>
<java.level>8</java.level>
<gitHubRepo>jenkinsci/leapwork-plugin</gitHubRepo>
<jenkins.version>2.440.1</jenkins.version>
</properties>
<name>Leapwork</name>
<url>https://github.com/${gitHubRepo}</url>
Expand All @@ -30,65 +27,22 @@
<dependency>
<!-- Pick up common dependencies for the selected LTS line: https://github.com/jenkinsci/bom#usage -->
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.277.x</artifactId>
<version>923.v08bdc07cd40f</version>
<artifactId>bom-2.440.x</artifactId>
<version>2815.vf5d6f093b_23e</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>jakarta-activation-api</artifactId>
<version>2.0.0-2</version>
</dependency>

</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ning</groupId>
<artifactId>async-http-client</artifactId>
<version>1.9.40</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.32</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.32</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>

<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>anything-goes-formatter</artifactId>
<version>1.0</version>
<groupId>io.jenkins.plugins</groupId>
<artifactId>gson-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
Expand All @@ -101,18 +55,26 @@
<version>3.0.0</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.1u2</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.32</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<scope>test</scope>
<groupId>io.jenkins.plugins</groupId>
<artifactId>jquery3-api</artifactId>
<version>3.7.1-2</version>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>commons-lang3-api</artifactId>
<version>3.13.0-62.v7d18e55f51e2</version>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>commons-text-api</artifactId>
<version>1.11.0-95.v22a_d30ee5d36</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class LeapworkJenkinsBridgeBuilder extends Builder implements SimpleBuild
private final String leapworkPort;
private final Secret leapworkAccessKey;
private String leapworkDelay;
private String leapworkTimeout;
private String leapworkDoneStatusAs;
private String leapworkReport;
private final String leapworkSchIds;
Expand All @@ -59,13 +60,14 @@ public class LeapworkJenkinsBridgeBuilder extends Builder implements SimpleBuild
// "DataBoundConstructor"
@DataBoundConstructor
public LeapworkJenkinsBridgeBuilder(String leapworkHostname, String leapworkPort, String leapworkAccessKey,
String leapworkDelay, String leapworkDoneStatusAs, String leapworkReport, String leapworkSchNames,
String leapworkDelay, String leapworkTimeout, String leapworkDoneStatusAs, String leapworkReport, String leapworkSchNames,
String leapworkSchIds, boolean leapworkWritePassedFlowKeyFrames, boolean leapworkEnableHttps) {

this.leapworkHostname = leapworkHostname;
this.leapworkPort = leapworkPort;
this.leapworkAccessKey = Secret.fromString(leapworkAccessKey);
this.leapworkDelay = leapworkDelay;
this.leapworkTimeout = leapworkTimeout;
this.leapworkDoneStatusAs = leapworkDoneStatusAs;
this.leapworkReport = leapworkReport;
this.leapworkSchIds = leapworkSchIds;
Expand All @@ -89,6 +91,11 @@ public void setLeapworkDelay(String leapworkDelay) {
this.leapworkDelay = leapworkDelay;
}

@DataBoundSetter
public void setLeapworkTimeout(String leapworkTimeout) {
this.leapworkTimeout = leapworkTimeout;
}

@DataBoundSetter
public void setLeapworkWritePassedFlowKeyFrames(boolean leapworkWritePassedFlowKeyFrames) {
this.leapworkWritePassedFlowKeyFrames = leapworkWritePassedFlowKeyFrames;
Expand Down Expand Up @@ -120,6 +127,10 @@ public String getLeapworkDelay() {
return leapworkDelay;
}

public String getLeapworkTimeout() {
return leapworkTimeout;
}

public String getLeapworkSchNames() {
return leapworkSchNames;
}
Expand Down Expand Up @@ -154,6 +165,8 @@ public void perform(final Run<?, ?> build, FilePath workspace, Launcher launcher

EnvVars env = build.getEnvironment(listener);
ArrayList<InvalidSchedule> invalidSchedules = new ArrayList<>();

int timeout = pluginHandler.getTimeout(leapworkTimeout, listener);

String workspacePath = pluginHandler.getWorkSpaceSafe(workspace, env);
this.leapworkReport = pluginHandler.getReportFileName(this.getLeapworkReport(),
Expand All @@ -174,8 +187,8 @@ public void perform(final Run<?, ?> build, FilePath workspace, Launcher launcher
.getScheduleVariablesRequestPart(getLeapworkScheduleVariables(), listener);

AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder()
.setReadTimeout(TIMEOUT_IN_SECONDS * 1000)
.setRequestTimeout(TIMEOUT_IN_SECONDS * 1000)
.setReadTimeout(timeout * 1000)
.setRequestTimeout(timeout * 1000)
.build();

try (AsyncHttpClient mainClient = new AsyncHttpClient(config)) {
Expand Down Expand Up @@ -206,7 +219,7 @@ public void perform(final Run<?, ?> build, FilePath workspace, Launcher launcher
if (runId != null) {
resultsMap.put(runId, run);
CollectScheduleRunResults(controllerApiHttpAddress, Secret.toString(leapworkAccessKey), runId,
schTitle, timeDelay, isDoneStatusAsSuccess, writePassedKeyframes, run, listener);
schTitle, timeDelay, timeout, isDoneStatusAsSuccess, writePassedKeyframes, run, listener);
} else
resultsMap.put(UUID.randomUUID(), run);

Expand Down Expand Up @@ -288,12 +301,17 @@ public void perform(final Run<?, ?> build, FilePath workspace, Launcher launcher
}

private static void CollectScheduleRunResults(String controllerApiHttpAddress, String accessKey, UUID runId,
String scheduleName, int timeDelay, boolean isDoneStatusAsSuccess, boolean writePassedKeyframes,
String scheduleName, int timeDelay, int timeout, boolean isDoneStatusAsSuccess, boolean writePassedKeyframes,
LeapworkRun resultRun, final TaskListener listener) throws AbortException, InterruptedException {
List<UUID> runItemsId = new ArrayList<>();
Object waiter = new Object();

AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder()
.setReadTimeout(timeout * 1000)
.setRequestTimeout(timeout * 1000)
.build();
// get statuses
try (AsyncHttpClient client = new AsyncHttpClient()) {
try (AsyncHttpClient client = new AsyncHttpClient(config)) {
boolean isStillRunning = true;

do {
Expand Down Expand Up @@ -380,7 +398,7 @@ private static void CollectScheduleRunResults(String controllerApiHttpAddress, S
String interruptedExceptionMessage = String.format(Messages.INTERRUPTED_EXCEPTION, e.getMessage());
listener.error(interruptedExceptionMessage);
RunItem invalidItem = new RunItem("Aborted run", "Cancelled", 0, e.getMessage(), scheduleName);
pluginHandler.stopRun(controllerApiHttpAddress, runId, scheduleName, accessKey, listener);
pluginHandler.stopRun(controllerApiHttpAddress, runId, scheduleName, accessKey, timeout, listener);
resultRun.incErrors();
resultRun.runItems.add(invalidItem);
} finally {
Expand All @@ -405,6 +423,7 @@ private void printPluginInputs(final TaskListener listener, String workspace) {
listener.getLogger().println(String.format(Messages.INPUT_SCHEDULE_NAMES_VALUE, getLeapworkSchNames()));
listener.getLogger().println(String.format(Messages.INPUT_SCHEDULE_IDS_VALUE, getLeapworkSchIds()));
listener.getLogger().println(String.format(Messages.INPUT_DELAY_VALUE, getLeapworkDelay()));
listener.getLogger().println(String.format(Messages.INPUT_TIMEOUT_VALUE, getLeapworkTimeout()));
listener.getLogger().println(String.format(Messages.INPUT_DONE_VALUE, getLeapworkDoneStatusAs()));
listener.getLogger().println(String.format(Messages.INPUT_WRITE_PASSED, isLeapworkWritePassedFlowKeyFrames()));
listener.getLogger().println(String.format(Messages.INPUT_VARIABLES, getLeapworkScheduleVariables()));
Expand Down Expand Up @@ -435,6 +454,7 @@ public boolean isApplicable(Class<? extends AbstractProject> aClass) {
}

public static final String DEFAULT_DELAY = "5";
public static final String DEFAULT_TIMEOUT = "300";
public static final String DEFAULT_REPORT_NAME = "report.xml";
public static final boolean DEFAULT_WRITE_PASSED_FLOW_KEYFRAMES = false;
public static final boolean DEFAULT_ENABLE_lEAPWORK_HTTPS = false;
Expand All @@ -453,10 +473,28 @@ public FormValidation doCheckLeapworkDelay(@QueryParameter("leapworkDelay") Stri
return FormValidation.ok();
}

public FormValidation doCheckLeapworkTimeout(@QueryParameter("leapworkTimeout") String timeout) {
int temp;
try {
temp = Integer.parseInt(timeout);

if (temp < 1) {
return FormValidation.error("Entered number must be higher than 0");
}
} catch (NumberFormatException ex) {
return FormValidation.error("Invalid number");
}
return FormValidation.ok();
}

public String getDefaultLeapworkDelay() {
return DEFAULT_DELAY;
}

public String getDefaultLeapworkTimeout() {
return DEFAULT_TIMEOUT;
}

public String getDefaultLeapworkReport() {
return DEFAULT_REPORT_NAME;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/Leapwork/Leapwork_plugin/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class Messages {
public static final String NO_DISK_SPACE = "No enough disk space to start schedule";
public static final String PORT_NUMBER_IS_INVALID = "Port number is invalid, setting to default %1$d";
public static final String TIME_DELAY_NUMBER_IS_INVALID = "Time delay number is invalid: %1$s, setting to default %2$s";
public static final String TIMEOUT_NUMBER_IS_INVALID = "Timeout number is invalid: %1$s, setting to default %2$s";
public static final String FULL_REPORT_FILE_PATH = "Creating report file by path: %1$s";
public static final String SCHEDULE_DISABLED = "Schedule %1$s[%2$s] is disabled";
public static final String INVALID_SCHEDULE_VARIABLE = "Failed to parse variable: %1$s";
Expand All @@ -90,6 +91,7 @@ public class Messages {
public static final String INPUT_SCHEDULE_NAMES_VALUE = "Schedule names: %1$s";
public static final String INPUT_SCHEDULE_IDS_VALUE = "Schedule ids: %1$s";
public static final String INPUT_DELAY_VALUE = "Delay between status checks: %1$s";
public static final String INPUT_TIMEOUT_VALUE = "Leapwork API Request/Response Timeout: %1$s";
public static final String INPUT_DONE_VALUE = "Done Status As: %1$s";
public static final String INPUT_WRITE_PASSED = "Write keyframes of passed flows: %1$b";
public static final String INPUT_VARIABLES = "Passed schedule variables: %1$s";
Expand Down
28 changes: 26 additions & 2 deletions src/main/java/com/Leapwork/Leapwork_plugin/PluginHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.ning.http.client.AsyncHttpClient;
import com.ning.http.client.AsyncHttpClientConfig;
import com.ning.http.client.Response;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
Expand Down Expand Up @@ -125,6 +126,23 @@ public int getTimeDelay(String rawTimeDelay, TaskListener listener) {
}
}

public int getTimeout(String rawTimeout, TaskListener listener) {
int defaultTimeout = 300;
try {
if (!rawTimeout.isEmpty() || !"".equals(rawTimeout))
return Integer.parseInt(rawTimeout);
else {
listener.getLogger()
.println(String.format(Messages.TIMEOUT_NUMBER_IS_INVALID, rawTimeout, defaultTimeout));
return defaultTimeout;
}
} catch (Exception e) {
listener.getLogger()
.println(String.format(Messages.TIMEOUT_NUMBER_IS_INVALID, rawTimeout, defaultTimeout));
return defaultTimeout;
}
}

public boolean isDoneStatusAsSuccess(String doneStatusAs) {
return doneStatusAs.contentEquals("Success");
}
Expand Down Expand Up @@ -388,13 +406,19 @@ private static UUID OnScheduleRunConnectionFailure(Exception e, TaskListener lis
}

@SuppressFBWarnings(value = "REC_CATCH_EXCEPTION")
public boolean stopRun(String controllerApiHttpAddress, UUID runId, String scheduleTitle, String accessKey,
public boolean stopRun(String controllerApiHttpAddress, UUID runId, String scheduleTitle, String accessKey, int timeout,
final TaskListener listener) {
boolean isSuccessfullyStopped = false;

listener.error(String.format(Messages.STOPPING_RUN, scheduleTitle, runId));
String uri = String.format(Messages.STOP_RUN_URI, controllerApiHttpAddress, runId.toString());
try (AsyncHttpClient client = new AsyncHttpClient()) {

AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder()
.setReadTimeout(timeout * 1000)
.setRequestTimeout(timeout * 1000)
.build();

try (AsyncHttpClient client = new AsyncHttpClient(config)) {

Response response = client.preparePut(uri).setBody("").setHeader("AccessKey", accessKey).execute().get();
client.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
@XmlRootElement(name = "testsuites")
@XmlAccessorType(XmlAccessType.NONE)
public final class RunCollection {

public int totalTests = 0;
private int totalTests = 0;

private int passedTests = 0;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<st:adjunct includes="io.jenkins.plugins.jquery3"/>
<!--
This jelly script is used for per-project configuration.
Expand Down Expand Up @@ -49,6 +50,9 @@
<f:entry title="Delay (seconds):" field="leapworkDelay">
<f:textbox name="leapworkDelay" default="${descriptor.DEFAULT_DELAY}"/>
</f:entry>
<f:entry title="Timeout (seconds):" field="leapworkTimeout">
<f:textbox name="leapworkTimeout" default="${descriptor.DEFAULT_TIMEOUT}"/>
</f:entry>
<f:entry title="Done Status:" field="leapworkDoneStatusAs">
<f:select />
</f:entry>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div>
The 'timeout' property represents the duration within which an operation or request expects to receive a response before considering it unsuccessful or timing out.<br>
It's measured in seconds, and the default value for this property is set to 300 seconds.
</div>
Loading

0 comments on commit c457cf3

Please sign in to comment.