Skip to content

Commit 03b26e7

Browse files
authored
Merge pull request #24 from SaranshBS/master
jenkins-pipleline-step-execution
2 parents f5a3057 + cd7424d commit 03b26e7

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/main/java/com/browserstack/automate/ci/jenkins/pipeline/AppUploadStepExecution.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ protected Void run() throws Exception {
4242
return null;
4343
}
4444

45-
EnvVars overrides = run.getEnvironment(taskListener);
46-
overrides.put(BrowserStackEnvVars.BROWSERSTACK_APP_ID, appId);
47-
HashMap<String, String> overridesMap = new HashMap<>(overrides);
45+
HashMap<String, String> overridesMap = new HashMap<String, String>();
46+
overridesMap.put(BrowserStackEnvVars.BROWSERSTACK_APP_ID, appId);
4847

4948
body = getContext().newBodyInvoker()
5049
.withContext(EnvironmentExpander.merge(getContext().get(EnvironmentExpander.class),

src/main/java/com/browserstack/automate/ci/jenkins/pipeline/BrowserStackPipelineStepExecution.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback;
1717
import org.jenkinsci.plugins.workflow.steps.EnvironmentExpander;
1818
import org.jenkinsci.plugins.workflow.steps.StepContext;
19-
import org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution;
19+
import org.jenkinsci.plugins.workflow.steps.StepExecution;
2020

2121
import java.io.IOException;
2222
import java.io.PrintStream;
@@ -25,7 +25,7 @@
2525
import static com.browserstack.automate.ci.common.logger.PluginLogger.log;
2626
import static com.browserstack.automate.ci.common.logger.PluginLogger.logError;
2727

28-
public class BrowserStackPipelineStepExecution extends SynchronousNonBlockingStepExecution<Void> {
28+
public class BrowserStackPipelineStepExecution extends StepExecution {
2929
private static final long serialVersionUID = -8810137779949881645L;
3030
private String credentialsId;
3131
private StepContext context;
@@ -42,7 +42,7 @@ protected BrowserStackPipelineStepExecution(StepContext context, String credenti
4242
}
4343

4444
@Override
45-
protected Void run() throws Exception {
45+
public boolean start() throws Exception {
4646
Run run = context.get(Run.class);
4747
TaskListener taskListener = context.get(TaskListener.class);
4848
Launcher launcher = context.get(Launcher.class);
@@ -55,7 +55,8 @@ protected Void run() throws Exception {
5555
if (credentials == null) {
5656
logError(logger, "Credentials id is invalid. Aborting!!!");
5757
tracker.sendError("No Credentials Available", true, "PipelineExecution");
58-
return null;
58+
context.onFailure(new Exception("No Credentials Available"));
59+
return true;
5960
}
6061

6162
if (credentials.hasUsername() && credentials.hasAccesskey()) {
@@ -87,7 +88,8 @@ protected Void run() throws Exception {
8788
localConfig, browserStackLocal);
8889

8990
EnvVars overrides = run.getEnvironment(taskListener);
90-
HashMap<String, String> overridesMap = new HashMap<String, String>(overrides);
91+
HashMap<String, String> overridesMap = new HashMap<String, String>();
92+
overridesMap.put(Constants.JENKINS_BUILD_TAG, overrides.get(Constants.JENKINS_BUILD_TAG));
9193
buildWrapperOperations.buildEnvVars(overridesMap);
9294

9395
body = getContext()
@@ -97,7 +99,7 @@ protected Void run() throws Exception {
9799

98100
tracker.pluginInitialized(overrides.get(Constants.JENKINS_BUILD_TAG),
99101
(this.localConfig != null), true);
100-
return null;
102+
return false;
101103
}
102104

103105
public void startBrowserStackLocal(String buildTag, PrintStream logger, String accessKey,

0 commit comments

Comments
 (0)