本文整理匯總了Java中hudson.model.Computer.currentComputer方法的典型用法代碼示例。如果您正苦於以下問題:Java Computer.currentComputer方法的具體用法?Java Computer.currentComputer怎麽用?Java Computer.currentComputer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hudson.model.Computer
的用法示例。
在下文中一共展示了Computer.currentComputer方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onStarted
import hudson.model.Computer; //導入方法依賴的package包/類
@Override
public void onStarted(Run run, TaskListener listener) {
Computer c = Computer.currentComputer();
if (c != null && c instanceof OneShotComputer) {
final OneShotSlave node = ((OneShotComputer) c).getNode();
if (node == null) {
throw new IllegalStateException("OneShotSlave node is null");
}
node.provision(listener);
}
}
示例2: onStarted
import hudson.model.Computer; //導入方法依賴的package包/類
@Override
public void onStarted(Run run, TaskListener listener) {
Computer c = Computer.currentComputer();
if (c instanceof HyperComputer) {
run.addAction(((HyperComputer) c).getProvisioner().getContext());
// TODO remove HyperSlaveAssignmentAction
}
}
示例3: perform
import hudson.model.Computer; //導入方法依賴的package包/類
@Override
public void perform(Run<?,?> build, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException{
Computer computer = Computer.currentComputer();
if (computer == null) {
throw new AbortException("The AppScan Source build step requires to be launched on a node");
}
perform(build, computer.getNode(), workspace, launcher, listener, build.getEnvironment(listener));
}
示例4: perform
import hudson.model.Computer; //導入方法依賴的package包/類
@Override
public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath ws, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException, IOException {
try {
CLIRunner runner = new CLIRunner(run, ws, launcher, listener);
Computer computer = Computer.currentComputer();
if (computer == null) {
throw new AbortException("The ansible playbook build step requires to be launched on a node");
}
String exe = AnsibleInstallation.getExecutable(ansibleName, AnsibleCommand.ANSIBLE, computer.getNode(), listener, run.getEnvironment(listener));
AnsibleAdHocCommandInvocation invocation = new AnsibleAdHocCommandInvocation(exe, run, ws, listener);
invocation.setHostPattern(hostPattern);
invocation.setInventory(inventory);
invocation.setModule(module);
invocation.setModuleCommand(command);
invocation.setSudo(sudo, sudoUser);
invocation.setForks(forks);
invocation.setCredentials(StringUtils.isNotBlank(credentialsId) ?
CredentialsProvider.findCredentialById(credentialsId, StandardUsernameCredentials.class, run) :
null);
invocation.setAdditionalParameters(additionalParameters);
invocation.setHostKeyCheck(hostKeyChecking);
invocation.setUnbufferedOutput(unbufferedOutput);
invocation.setColorizedOutput(colorizedOutput);
if (!invocation.execute(runner)) {
throw new AbortException("Ansible Ad-Hoc command execution failed");
}
} catch (IOException ioe) {
Util.displayIOException(ioe, listener);
ioe.printStackTrace(listener.fatalError(hudson.tasks.Messages.CommandInterpreter_CommandFailed()));
throw ioe;
} catch (AnsibleInvocationException aie) {
listener.fatalError(aie.getMessage());
throw new AbortException(aie.getMessage());
}
}
示例5: perform
import hudson.model.Computer; //導入方法依賴的package包/類
@Override
public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath ws, @Nonnull Launcher launcher, @Nonnull TaskListener listener)
throws InterruptedException, IOException
{
Computer computer = Computer.currentComputer();
if (computer == null) {
throw new AbortException("The ansible playbook build step requires to be launched on a node");
}
perform(run, computer.getNode(), ws, launcher, listener, run.getEnvironment(listener));
}
示例6: computeJdkToUse
import hudson.model.Computer; //導入方法依賴的package包/類
/**
* Set the JDK to use to start ZAP.
*
* @param build
* @param listener the listener to display log during the job execution in jenkins
* @param env list of environment variables. Used to set the path to the JDK
* @throws IOException
* @throws InterruptedException
*/
private void computeJdkToUse(AbstractBuild<?, ?> build,
BuildListener listener, EnvVars env) throws IOException, InterruptedException {
JDK jdkToUse = getJdkToUse(build.getProject());
if (jdkToUse != null) {
Computer computer = Computer.currentComputer();
// just in case we are not in a build
if (computer != null) {
jdkToUse = jdkToUse.forNode(computer.getNode(), listener);
}
jdkToUse.buildEnvVars(env);
}
}
示例7: onStarted
import hudson.model.Computer; //導入方法依賴的package包/類
@Override
public void onStarted(Run<?, ?> run, TaskListener listener) {
final Computer computer = Computer.currentComputer();
if (computer instanceof DockerComputer) {
final DockerTransientNode node = ((DockerComputer) computer).getNode();
run.addAction(new DockerBuildAction(node));
}
}
示例8: consolidateEnvVars
import hudson.model.Computer; //導入方法依賴的package包/類
protected Map<String, String> consolidateEnvVars(TaskListener listener,
AbstractBuild<?, ?> build,
Launcher launcher) {
// EnvVars extends TreeMap
TreeMap<String, String> overrides = new TreeMap<String, String>();
// merge from all potential sources
if (build != null) {
try {
EnvVars buildEnv = build.getEnvironment(listener);
if (isVerbose())
listener.getLogger()
.println("build env vars: " + buildEnv);
overrides.putAll(buildEnv);
} catch (IOException | InterruptedException e) {
if (isVerbose())
e.printStackTrace(listener.getLogger());
}
}
try {
EnvVars computerEnv = null;
Computer computer = Computer.currentComputer();
if (computer != null) {
computerEnv = computer.getEnvironment();
} else {
if (launcher != null)
computer = launcher.getComputer();
if (computer != null) {
computerEnv = computer.getEnvironment();
}
}
if (isVerbose())
listener.getLogger().println(
"computer env vars: " + computerEnv);
if (computerEnv != null)
overrides.putAll(computerEnv);
} catch (IOException | InterruptedException e2) {
if (isVerbose())
e2.printStackTrace(listener.getLogger());
}
return overrides;
}
示例9: runingOnMaster
import hudson.model.Computer; //導入方法依賴的package包/類
public static boolean runingOnMaster() {
return Computer.currentComputer() instanceof MasterComputer;
}