Skip to content

Commit

Permalink
JENKINS-15597 Use authentication details from build action
Browse files Browse the repository at this point in the history
  • Loading branch information
rossrowe committed Oct 23, 2012
1 parent e50ab9d commit dfb6e74
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Expand Up @@ -52,6 +52,14 @@ public SauceOnDemandBuildAction(AbstractBuild<?, ?> build, String username, Stri
this.accessKey = accessKey;
}

public String getAccessKey() {
return accessKey;
}

public String getUsername() {
return username;
}

public AbstractBuild<?, ?> getBuild() {
return build;
}
Expand Down
Expand Up @@ -27,6 +27,7 @@
import hudson.Extension;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.Action;
import hudson.model.BuildListener;
import hudson.model.Descriptor;
import hudson.tasks.junit.CaseResult;
Expand Down Expand Up @@ -57,7 +58,14 @@ public SauceOnDemandReportPublisher() {

@Override
public SauceOnDemandReportFactory getTestData(AbstractBuild<?, ?> build, Launcher launcher, BuildListener buildListener, TestResult testResult) throws IOException, InterruptedException {
SauceREST sauceREST = new SauceREST(PluginImpl.get().getUsername(), Secret.toString(PluginImpl.get().getApiKey()));
SauceOnDemandBuildAction buildAction = build.getAction(SauceOnDemandBuildAction.class);
if (buildAction == null) {
//shouldn't happen, but if it does, log an error and return null
buildListener.getLogger().println("Unable to retrieve the Sauce Build Action, please contact Sauce Labs Support");
return null;
}

SauceREST sauceREST = new SauceREST(buildAction.getUsername(), buildAction.getAccessKey());

buildListener.getLogger().println("Scanning for Sauce OnDemand test data...");
List<String> lines = IOUtils.readLines(build.getLogReader());
Expand Down

0 comments on commit dfb6e74

Please sign in to comment.