Source:
public synchronized void init() { running = true; new Thread(new Runnable() { @Override public void run() { try { String targetUser = mesosCloud.getSlavesUser(); String webUrl = Jenkins.getInstance().getRootUrl(); if (webUrl == null) webUrl = System.getenv("JENKINS_URL"); StandardUsernamePasswordCredentials credentials = mesosCloud.getCredentials(); String principal = credentials == null ? "" : credentials.getUsername(); String secret = credentials == null ? "" : Secret.toString(credentials.getPassword()); FrameworkInfo framework = FrameworkInfo.newBuilder() .setUser(targetUser == null ? "" : targetUser) .setName(mesosCloud.getFrameworkName()) .setPrincipal(principal) .setCheckpoint(mesosCloud.isCheckpoint()) .setWebuiUrl(webUrl != null ? webUrl : "") .build(); LOGGER.info("Initializing the Mesos driver with options" + "\n" + "Framework Name: " + framework.getName() + "\n" + "Principal: " + principal + "\n" + "Checkpointing: " + framework.getCheckpoint() ); if (StringUtils.isNotBlank(secret)) { Credential credential = Credential.newBuilder() .setPrincipal(principal) .setSecret(ByteString.copyFromUtf8(secret)) .build(); LOGGER.info("Authenticating with Mesos master with principal " + principal); driver = new MesosSchedulerDriver(JenkinsScheduler.this, framework, mesosCloud.getMaster(), credential); } else { driver = new MesosSchedulerDriver(JenkinsScheduler.this, framework, mesosCloud.getMaster()); } Status runStatus = driver.run(); if (runStatus != Status.DRIVER_STOPPED) { LOGGER.severe("The Mesos driver was aborted! Status code: " + runStatus.getNumber()); } } catch (RuntimeException e) { LOGGER.log(Level.SEVERE, "Caught a RuntimeException", e); } finally { driver = null; running = false; } } }).start(); }

Target:
public synchronized void init() { running = true; new Thread(new Runnable() { @Override public void run() { try { String targetUser = mesosCloud.getSlavesUser(); String webUrl = Jenkins.getInstance().getRootUrl(); if (webUrl == null) webUrl = System.getenv("JENKINS_URL"); StandardUsernamePasswordCredentials credentials = mesosCloud.getCredentials(); String principal = credentials == null ? "jenkins" : credentials.getUsername(); String secret = credentials == null ? "" : Secret.toString(credentials.getPassword()); FrameworkInfo framework = FrameworkInfo.newBuilder() .setUser(targetUser == null ? "" : targetUser) .setName(mesosCloud.getFrameworkName()) .setPrincipal(principal) .setCheckpoint(mesosCloud.isCheckpoint()) .setWebuiUrl(webUrl != null ? webUrl : "") .build(); LOGGER.info("Initializing the Mesos driver with options" + "\n" + "Framework Name: " + framework.getName() + "\n" + "Principal: " + principal + "\n" + "Checkpointing: " + framework.getCheckpoint() ); if (StringUtils.isNotBlank(secret)) { Credential credential = Credential.newBuilder() .setPrincipal(principal) .setSecret(ByteString.copyFromUtf8(secret)) .build(); LOGGER.info("Authenticating with Mesos master with principal " + credential.getPrincipal()); driver = new MesosSchedulerDriver(JenkinsScheduler.this, framework, mesosCloud.getMaster(), credential); } else { driver = new MesosSchedulerDriver(JenkinsScheduler.this, framework, mesosCloud.getMaster()); } Status runStatus = driver.run(); if (runStatus != Status.DRIVER_STOPPED) { LOGGER.severe("The Mesos driver was aborted! Status code: " + runStatus.getNumber()); } } catch(RuntimeException e) { LOGGER.log(Level.SEVERE, "Caught a RuntimeException", e); } finally { if (driver != null) { driver.abort(); } driver = null; running = false; } } }).start(); }