Skip to content
Permalink
Browse files

Handle passing data around slightly differently so slaves don't crash…

… trying to build JENKINS-31529
  • Loading branch information
Gavin Mogan
Gavin Mogan committed Nov 12, 2015
1 parent eb79321 commit f8ab6eef89ae7d2c22efa2b865c6f8aa1a39fb9a
@@ -2,6 +2,7 @@

import com.saucelabs.saucerest.SauceREST;
import hudson.Plugin;
import hudson.PluginManager;
import hudson.ProxyConfiguration;
import jenkins.model.Jenkins;

@@ -15,18 +16,24 @@
* @author Ross Rowe
*/
public class JenkinsSauceREST extends SauceREST {
public static String pluginVersion = "";
public JenkinsSauceREST(String username, String accessKey) {
super(username, accessKey);
}

public static String getPluginVersion() {
return pluginVersion;
}

public static void setPluginVersion(String pluginVersion) {
JenkinsSauceREST.pluginVersion = pluginVersion;
}

@Override
protected String getUserAgent() {
Plugin p = PluginImpl.get();
String pluginVersion = p == null ? "UNKNOWN" : p.getWrapper().getVersion();
return super.getUserAgent() + " " +
"Jenkins/" + Jenkins.VERSION.toString() + " " +
"JenkinsSauceOnDemand/" + pluginVersion;
"JenkinsSauceOnDemand/" + getPluginVersion();
}

@Override
@@ -142,6 +142,7 @@ public String calcHMAC(String username, String accessKey, String jobId) throws N

@Override
public void start() throws Exception {
JenkinsSauceREST.setPluginVersion(getWrapper().getVersion());
// backward compatibility with the legacy class name
Items.XSTREAM.alias("hudson.plugins.sauce_ondemand.SoDBuildWrapper", SauceOnDemandBuildWrapper.class);
Items.XSTREAM.alias("hudson.plugins.sauce__ondemand.SoDBuildWrapper", SauceOnDemandBuildWrapper.class);
@@ -176,7 +177,9 @@ public DescriptorImpl getDescriptor() {
}

public static PluginImpl get() {
return Jenkins.getInstance().getPlugin(PluginImpl.class);
Jenkins j = Jenkins.getInstance();
if (j == null) { return null; }
return j.getPlugin(PluginImpl.class);
}

public String getSauceConnectDirectory() {

0 comments on commit f8ab6ee

Please sign in to comment.
You can’t perform that action at this time.