本文整理汇总了Java中jenkins.security.MasterToSlaveCallable类的典型用法代码示例。如果您正苦于以下问题:Java MasterToSlaveCallable类的具体用法?Java MasterToSlaveCallable怎么用?Java MasterToSlaveCallable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MasterToSlaveCallable类属于jenkins.security包,在下文中一共展示了MasterToSlaveCallable类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: perform
import jenkins.security.MasterToSlaveCallable; //导入依赖的package包/类
/**
* This method is called whenever the build step is executed.
*
* @param build A Run object
* @param filePath A FilePath object
* @param launcher A Launcher object
* @param listener A BuildListener object
*/
@Override
public void perform(@Nonnull final Run<?, ?> build,
@Nonnull final FilePath filePath,
@Nonnull final Launcher launcher,
@Nonnull final TaskListener listener) throws InterruptedException, IOException {
this.logger = listener.getLogger();
log(Messages.DtrackBuilder_Publishing());
final String projectId = PluginUtil.substituteVariable(build, listener, this.projectId);
final String artifact = PluginUtil.substituteVariable(build, listener, this.artifact);
boolean success = launcher.getChannel().call(new MasterToSlaveCallable<Boolean, IOException>() {
public Boolean call() throws IOException {
return upload(listener, projectId, artifact, isScanResult, filePath);
}
});
if (!success) {
build.setResult(Result.FAILURE);
}
}
示例2: gatherEnvVarsNode
import jenkins.security.MasterToSlaveCallable; //导入依赖的package包/类
@Nonnull
private static Map<String, String> gatherEnvVarsNode(@Nonnull Job<?, ?> job, @Nonnull Node node) throws EnvInjectException {
final FilePath rootPath = node.getRootPath();
if (rootPath == null) {
//TODO: better than the original NPE. But maybe it's preferable to have more intelligent handling
throw new EnvInjectException("Cannot retrieve Environment variables from the offline node");
}
try {
Map<String, String> envVars = new EnvVars(rootPath.act(new MasterToSlaveCallable<Map<String, String>, EnvInjectException>() {
private static final long serialVersionUID = 1L;
@Override
public Map<String, String> call() throws EnvInjectException {
return EnvVars.masterEnvVars;
}
}));
envVars.put("NODE_NAME", node.getNodeName());
envVars.put("NODE_LABELS", Util.join(node.getAssignedLabels(), " "));
if (job instanceof AbstractProject) {
FilePath wFilePath = ((AbstractProject)job).getSomeWorkspace();
if (wFilePath != null) {
envVars.put("WORKSPACE", wFilePath.getRemote());
}
}
return envVars;
} catch (IOException | InterruptedException ioe) {
throw new EnvInjectException(ioe);
}
}
示例3: start
import jenkins.security.MasterToSlaveCallable; //导入依赖的package包/类
public void start(Launcher launcher) throws Exception {
launcher.getChannel().call(new MasterToSlaveCallable<Void, Exception>() {
@Override
public Void call() throws Exception {
JenkinsBrowserStackLocal.this.start();
return null;
}
});
}
示例4: stop
import jenkins.security.MasterToSlaveCallable; //导入依赖的package包/类
public void stop(Launcher launcher) throws Exception {
launcher.getChannel().call(new MasterToSlaveCallable<Void, Exception>() {
@Override
public Void call() throws Exception {
JenkinsBrowserStackLocal.this.stop();
return null;
}
});
}
示例5: perform
import jenkins.security.MasterToSlaveCallable; //导入依赖的package包/类
/**
* This method is called whenever the build step is executed.
*
* @param build A Run object
* @param filePath A FilePath object
* @param launcher A Launcher object
* @param listener A BuildListener object
*/
@Override
public void perform(@Nonnull final Run<?, ?> build,
@Nonnull final FilePath filePath,
@Nonnull final Launcher launcher,
@Nonnull final TaskListener listener) throws InterruptedException, IOException {
ConsoleLogger logger = new ConsoleLogger(listener);
if (useSsc && StringUtils.isBlank(getDescriptor().sscUrl)) {
logger.log(Messages.unspecifiedUrl_ssc());
build.setResult(Result.FAILURE);
return;
}
if (!useSsc && StringUtils.isBlank(getDescriptor().controllerUrl)) {
logger.log(Messages.unspecifiedUrl_controller());
build.setResult(Result.FAILURE);
return;
}
final Options options = new Options();
options.setEnvVars(build.getEnvironment(listener));
options.setCommand(generateCommand(build, listener));
options.setArgs(generateArgs(build, listener));
options.setRules(preProcessRules(build, listener));
options.setScanOpts(generateScanOptions(build, listener));
options.setWorkspace(filePath.getRemote());
EnvVars env = build.getEnvironment(listener);
String command = launcher.decorateByEnv(env).getChannel().call(new MasterToSlaveCallable<String, IOException>() {
public String call() throws IOException {
final FortifyCloudScanExecutor executor = new FortifyCloudScanExecutor(listener, options);
return executor.prepare();
}
});
String versionCommand = launcher.decorateByEnv(env).getChannel().call(new MasterToSlaveCallable<String, IOException>() {
public String call() throws IOException {
return CommandUtil.generateShellCommand(new String[] {options.getCommand(), "-version"});
}
});
launcher.launch().cmdAsSingleString(versionCommand).envs(env).stdout(logger).start().join();
if (launcher.launch().cmdAsSingleString(command).envs(env).stdout(logger).start().join() == 0) {
build.setResult(Result.SUCCESS);
} else {
build.setResult(Result.FAILURE);
}
}
示例6: newKeyMaterialFactory
import jenkins.security.MasterToSlaveCallable; //导入依赖的package包/类
/**
* Makes the credentials available locally and returns {@link KeyMaterialFactory} that gives you the parameters
* needed to access it.
*
* This is done by inserting the token into {@code ~/.dockercfg}
*/
public KeyMaterialFactory newKeyMaterialFactory(final @Nonnull URL endpoint, @Nonnull VirtualChannel target, @CheckForNull Launcher launcher, final @Nonnull TaskListener listener) throws InterruptedException, IOException {
target.call(new MasterToSlaveCallable<Void, IOException>() {
/**
* Insert the token into {@code ~/.dockercfg}
*/
@Override
public Void call() throws IOException {
// TODO: TF: Should this not be done via docker login (possibly preceded by a logout) ?
JSONObject json;
JSONObject auths;
synchronized (DockerRegistryToken.class) {// feeble attempt at serializing access to ~/.dockercfg
File config = new File(System.getProperty("user.home"), ".docker/config.json");
if (config.exists()) {
json = JSONObject.fromObject(FileUtils.readFileToString(config, "UTF-8"));
auths = json.getJSONObject("auths");
} else {
config = new File(System.getProperty("user.home"), ".dockercfg");
if (config.exists()) {
auths = json = JSONObject.fromObject(FileUtils.readFileToString(config, "UTF-8"));
} else {
// Use legacy .dockercfg to ensure this works well with pre-1.7 docker client
// client will pick this one if .docker/config.json does not yet exists
auths = json = new JSONObject();
}
}
auths.put(endpoint.toString(), new JSONObject()
.accumulate("auth", getToken())
.accumulate("email", getEmail()));
FileUtils.writeStringToFile(config, json.toString(2), "UTF-8");
listener.getLogger().println("Wrote authentication to " + config);
}
return null;
}
});
// risky to clean up ~/.dockercfg as multiple builds might try to use the same credentials
return KeyMaterialFactory.NULL;
}