Java 类hudson.model.Computer 实例源码

项目:external-workspace-manager-plugin    文件:ConfigMigrationTest.java   
@LocalData
@Test
public void localRootPathToNodeMountPoint() throws Exception {

    // The node configuration version 1.0.0 contains a localRootPath field.
    // This tests that future versions load this field as nodeMountPoint,
    // in other words it tests NodeDisk.readResolve()

    Computer computer = jr.getInstance().getComputer("node1");
    Node node = computer.getNode();
    DescribableList<NodeProperty<?>,NodePropertyDescriptor> props = node.getNodeProperties();
    ExternalWorkspaceProperty exwsProp = props.get(ExternalWorkspaceProperty.class);

    List<NodeDiskPool> diskPools = exwsProp.getNodeDiskPools();
    assertThat(diskPools.size(), is(1));

    NodeDiskPool diskPool = diskPools.get(0);
    assertThat(diskPool.getDiskPoolRefId(), is ("dp1"));

    List<NodeDisk> disks = diskPool.getNodeDisks();
    assertThat(disks.size(), is(1));

    NodeDisk disk = disks.get(0);
    assertThat(disk.getDiskRefId(), is("d1"));
    assertThat(disk.getNodeMountPoint(), is("/tmp/dp1/d1"));
}
项目:cloud-stats-plugin    文件:CloudStatisticsTest.java   
@Test @Issue("JENKINS-41037")
public void modifiedWhileSerialized() throws Exception {
    final CloudStatistics cs = CloudStatistics.get();
    final CloudStatistics.ProvisioningListener l = CloudStatistics.ProvisioningListener.get();
    final ProvisioningActivity activity = l.onStarted(new ProvisioningActivity.Id("Cloud", "template", "PAOriginal"));
    final StatsModifyingAttachment blocker = new StatsModifyingAttachment(OK, "Blocker");
    Computer.threadPoolForRemoting.submit(new Callable<Object>() {
        @Override public Object call() throws Exception {
            cs.attach(activity, PROVISIONING, blocker);
            cs.persist();
            return null;
        }
    }).get();

    String serialized = cs.getConfigFile().asString();
    assertThat(serialized, not(containsString("ConcurrentModificationException")));
    assertThat(serialized, not(containsString("active class=\"linked-hash-set\"")));
    assertThat(serialized, containsString("Blocker"));
    assertThat(serialized, containsString("PAOriginal"));
    assertThat(serialized, containsString("PAModifying"));
    assertThat(serialized, containsString("active class=\"java.util.concurrent.CopyOnWriteArrayList\""));
}
项目:ssh2easy-plugin    文件:CloudCIAuthorizationStrategy.java   
public List<PermissionGroup> getGroups(String typeString) {
    AclType type = AclType.parseAclType(typeString);
    List<PermissionGroup> groups;
    switch (type) {
    case GLOBAL: {
        groups = new ArrayList<PermissionGroup>(
                PermissionGroup.getAll());
        groups.remove(PermissionGroup.get(Permission.class));
        break;
    }
    case PROJECT: {
        groups = new ArrayList<PermissionGroup>(
                PermissionGroup.getAll());
        groups.remove(PermissionGroup.get(Permission.class));
        groups.remove(PermissionGroup.get(Jenkins.class));
        groups.remove(PermissionGroup.get(Computer.class));
        groups.remove(PermissionGroup.get(View.class));
        break;
    }
    default:
        groups = null;
    }
    return groups;
}
项目:openedge-jenkins-plugin    文件:OpenEdgeBuildWrapper.java   
@Override
public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
    OpenEdgeInstallation installation = getOpenEdgeInstallation();
    if (installation != null) {
        installation = installation.forNode(Computer.currentComputer().getNode(), listener);
    }

    // Add DLC variable and modify PATH
    final OpenEdgeInstallation install = installation;
    return new Environment() {
        @Override
        public void buildEnvVars(Map<String, String> env) {
            if (install != null) {
                EnvVars envVars = new EnvVars();
                install.buildEnvVars(envVars);
                env.putAll(envVars);
            }
        }
    };
}
项目:amazon-ecs-plugin    文件:ECSCloud.java   
@Override
public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload) {
    try {

        List<NodeProvisioner.PlannedNode> r = new ArrayList<NodeProvisioner.PlannedNode>();
        final ECSTaskTemplate template = getTemplate(label);

        for (int i = 1; i <= excessWorkload; i++) {

            r.add(new NodeProvisioner.PlannedNode(template.getDisplayName(), Computer.threadPoolForRemoting
                    .submit(new ProvisioningCallback(template, label)), 1));
        }
        return r;
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Failed to provision ECS slave", e);
        return Collections.emptyList();
    }
}
项目:yet-another-docker-plugin    文件:ContainerRecordUtils.java   
public static void attachFacet(Run<?, ?> run, TaskListener listener) {
    final Executor executor = run.getExecutor();
    if (executor == null) {
        return;
    }

    final Computer owner = executor.getOwner();
    DockerComputer dockerComputer;
    if (owner instanceof DockerComputer) {
        dockerComputer = (DockerComputer) owner;
        try {
            DockerFingerprints.addRunFacet(
                    createRecordFor(dockerComputer),
                    run
            );
        } catch (IOException | ParseException e) {
            listener.error("Can't add Docker fingerprint to run.");
            LOG.error("Can't add fingerprint to run {}", run, e);
        }
    }


}
项目:yet-another-docker-plugin    文件:DockerOnceRetentionStrategy.java   
protected void done(final AbstractCloudComputer<?> c) {
    c.setAcceptingTasks(false); // just in case
    synchronized (this) {
        if (terminating) {
            return;
        }
        terminating = true;
    }

    final Future<?> submit = Computer.threadPoolForRemoting.submit(() -> {
            try {
                AbstractCloudSlave node = c.getNode();
                if (node != null) {
                    node.terminate();
                }
            } catch (InterruptedException | IOException e) {
                LOG.warn("Failed to terminate " + c.getName(), e);
                synchronized (DockerOnceRetentionStrategy.this) {
                    terminating = false;
                }
            }
        }
    );
}
项目:openshift-deployer-plugin    文件:DeploymentPackageTest.java   
@Before
public void setup() throws IOException {
    // Define a Test Directory
    File localPath = File.createTempFile("TestGitRepository", "");

    // prepare a new folder
    if(localPath.exists()) localPath.delete();

    // create the repository
    repository = FileRepositoryBuilder.create(new File(localPath, ".git"));
    repository.create();

    // Setup Mocks
    when(build.getWorkspace()).thenReturn(new FilePath(new File(getClass().getResource("/").getPath())));
    when(listener.getLogger()).thenReturn(System.out);

    when(app.getName()).thenReturn("testapp");
    when(app.getGitUrl()).thenReturn(repository.getDirectory().getAbsolutePath());

    mockStatic(Computer.class);
    PowerMockito.when(Computer.currentComputer()).thenReturn(mock(MasterComputer.class));

}
项目:metrics-plugin    文件:JenkinsMetricProviderImpl.java   
private synchronized void updateMetrics() {
    final Jenkins jenkins = Jenkins.getInstance();
    if (jenkins != null) {
        Set<Computer> forRetention = new HashSet<Computer>();
        for (Node node : jenkins.getNodes()) {
            Computer computer = node.toComputer();
            if (computer == null) {
                continue;
            }
            forRetention.add(computer);
            getOrCreateTimer(computer);
        }
        MetricRegistry metricRegistry = Metrics.metricRegistry();
        for (Map.Entry<Computer, Timer> entry : computerBuildDurations.entrySet()) {
            if (forRetention.contains(entry.getKey())) {
                continue;
            }
            // purge dead nodes
            metricRegistry.remove(name("jenkins", "node", entry.getKey().getName(), "builds"));
        }
        computerBuildDurations.keySet().retainAll(forRetention);
    }

}
项目:metrics-plugin    文件:JenkinsMetricProviderImpl.java   
@Override
public synchronized void onStarted(Run run, TaskListener listener) {
    JenkinsMetricProviderImpl instance = instance();
    if (instance != null) {
        List<Timer.Context> contextList = new ArrayList<Timer.Context>();
        contextList.add(instance.jenkinsJobBuildingTime.time());
        Executor executor = run.getExecutor();
        if (executor != null) {
            Computer computer = executor.getOwner();
            Timer timer = instance.getOrCreateTimer(computer);
            contextList.add(timer.time());
        }
        contexts.put(run, contextList);
    }
    ScheduledRate.instance().addAction(run);
}
项目:DotCi    文件:DbBackedBuild.java   
@Override
@Exported
public Executor getExecutor() {
    final Jenkins jenkins = Jenkins.getInstance();
    if (jenkins == null) {
        return null;
    }
    for (final Computer computer : jenkins.getComputers()) {
        for (final Executor executor : computer.getExecutors()) {
            if (isCurrent(executor)) {
                return executor;
            }
        }
    }
    return null;
}
项目:jenkins-inheritance-plugin    文件:NodeFileSeparator.java   
private String getRawSepFor(Computer c) {
    if (c == null) { return null; }
    String sep = null;
    //Fetch via System properties
    try {
        Map<Object,Object> map = c.getSystemProperties();
        if (map != null && map.containsKey("file.separator")) {
            Object o = map.get("file.separator");
            if (o instanceof String) {
                sep = (String)o;
                if (sep.equals("\\") || sep.equals("/")) {
                    return sep;
                }
            }
        }
    } catch (IOException | InterruptedException e) {
        return null;
    }
    return sep;
}
项目:support-core-plugin    文件:SupportPlugin.java   
public static void setLogLevel(Level level) {
    SupportPlugin instance = getInstance();
    instance.handler.setLevel(level);
    for (Node n : Jenkins.getInstance().getNodes()) {
        Computer c = n.toComputer();
        if (c == null) {
            continue;
        }
        VirtualChannel channel = c.getChannel();
        if (channel != null) {
            try {
                channel.callAsync(new LogUpdater(level));
            } catch (IOException e) {
                // ignore
            }
        }
    }
}
项目:scoring-load-balancer    文件:DummySubTask.java   
@Override
public void run()
{
    Node node = Computer.currentComputer().getNode();
    LOGGER.info(String.format("%s was run on %s", DummySubTask.this.getDisplayName(), node.getNodeName()));

    try
    {
        Thread.sleep(DummySubTask.this.duration);
    }
    catch(InterruptedException e)
    {
        LOGGER.log(Level.SEVERE, "", e);
        return;
    }

    DummySubTask.this.lastBuiltOn = node;
}
项目:gearman-plugin    文件:ComputerListenerImpl.java   
@Override
public void onOnline(Computer c, TaskListener listener) throws IOException,
        InterruptedException {
    // gets called when master goes into online state
    // gets called when existing slave re-connects
    // gets called when new slave goes into online state
    logger.info("---- " + ComputerListenerImpl.class.getName() + ":"
            + " onOnline computer " + c);

    // update functions only when gearman-plugin is enabled
    if (!GearmanPluginConfig.get().enablePlugin()) {
        return;
    }

    GearmanProxy gp = GearmanProxy.getInstance();
    /*
     * Spawn management executor worker if one doesn't exist yet.
     * This worker does not need any executors. It only needs
     * to work with gearman.
     */
    gp.createManagementWorker();

    // on creation of new slave
    gp.createExecutorWorkersOnNode(c);
}
项目:gearman-plugin    文件:GearmanProxy.java   
public void onBuildFinalized(Run r) {
    Computer computer = r.getExecutor().getOwner();
    // A build just finished, so let the AvailabilityMonitor
    // associated with its node wake up any workers who may be
    // waiting for the lock.

    AvailabilityMonitor availability = null;
    synchronized(gewtHandles) {
        for (ExecutorWorkerThread t : gewtHandles) {
            if (t.getComputer() == computer) {
                availability = t.getAvailability();
            }
        }
    }
    if (availability != null) {
        availability.wake();
    }
}
项目:gearman-plugin    文件:GearmanProxy.java   
public CauseOfBlockage canTake(Node node,
                               Queue.BuildableItem item) {
    // Ask the AvailabilityMonitor for this node if it's okay to
    // run this build.
    ExecutorWorkerThread workerThread = null;

    synchronized(gewtHandles) {
        Computer computer = node.toComputer();
        for (ExecutorWorkerThread t : gewtHandles) {
            if (t.getComputer() == computer) {
                workerThread = t;
                break;
            }
        }
    }

    if (workerThread != null) {
        if (workerThread.getAvailability().canTake(item)) {
            return null;
        } else {
            return new CauseOfBlockage.BecauseNodeIsBusy(node);
        }
    }
    return null;
}
项目:gearman-plugin    文件:CustomGearmanFunctionFactory.java   
private static GearmanFunction createFunctionInstance(String className, AbstractProject<?,?> project, Computer computer, String masterName, MyGearmanWorkerImpl worker) {

        GearmanFunction f = null;
        try {

            Class<?> c = Class.forName(className);
            Constructor<?> con = c.getConstructor(new Class[]{AbstractProject.class, Computer.class, String.class, MyGearmanWorkerImpl.class});
            Object o = con.newInstance(new Object[] {project, computer, masterName, worker});

            if (o instanceof GearmanFunction) {
                f = (GearmanFunction) o;
            } else {
                LOG.warn("Specified class " + className +
                        " is not a Gearman Function ");
            }
        } catch (Exception e) {
            LOG.warn("Unable to create instance of " +
                    "Function: " + className, e);
        }
        return f;
    }
项目:envinject-api-plugin    文件:EnvVarsResolver.java   
@CheckForNull
private static Node getMasterNode() {
    final Jenkins jenkins  = Jenkins.getInstance();
    if (jenkins == null) {
        return null;
    }
    Computer computer = jenkins.toComputer();
    if (computer == null) {
        return null; //Master can have no executors
    }
    return computer.getNode();
}
项目:cloud-stats-plugin    文件:CloudStatistics.java   
@Override
public void preLaunch(Computer c, TaskListener taskListener) throws IOException, InterruptedException {
    ProvisioningActivity.Id id = getIdFor(c);
    if (id == null) return;
    ProvisioningActivity activity = stats.getActivityFor(id);
    if (activity == null) return;

    // Do not enter second time on relaunch
    boolean entered = activity.enterIfNotAlready(ProvisioningActivity.Phase.LAUNCHING);
    if (entered) {
        stats.persist();
    }
}
项目:cloud-stats-plugin    文件:CloudStatistics.java   
@Override
public void onLaunchFailure(Computer c, TaskListener taskListener) throws IOException, InterruptedException {
    ProvisioningActivity.Id id = getIdFor(c);
    if (id == null) return;
    ProvisioningActivity activity = stats.getActivityFor(id);
    if (activity == null) return;

    // TODO attach details
    // ...
}
项目:cloud-stats-plugin    文件:CloudStatistics.java   
@Override
public void onOnline(Computer c, TaskListener listener) throws IOException, InterruptedException {
    ProvisioningActivity.Id id = getIdFor(c);
    if (id == null) return;
    ProvisioningActivity activity = stats.getActivityFor(id);
    if (activity == null) return;

    // Do not enter second time on relaunch
    boolean entered = activity.enterIfNotAlready(ProvisioningActivity.Phase.OPERATING);
    if (entered) {
        stats.persist();
    }
}
项目:cloud-stats-plugin    文件:CloudStatistics.java   
private static @CheckForNull ProvisioningActivity.Id getIdFor(Computer computer) {
    if (computer instanceof Jenkins.MasterComputer) return null;
    if (!(computer instanceof AbstractCloudComputer)) return null;

    if (!(computer instanceof TrackedItem)) {
        logTypeNotSupported(computer.getClass());
        return null;
    }

    return ((TrackedItem) computer).getId();
}
项目:hyper-slaves-plugin    文件:OneShotSlave.java   
@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);
    }
}
项目:hyper-slaves-plugin    文件:HyperSlave.java   
@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
    }
}
项目:appscansource-scanner    文件:AppScanSourceBuilder.java   
@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));
}
项目:pipeline-maven-plugin    文件:WithMavenStepExecution.java   
/**
 * Gets the computer for the current launcher.
 *
 * @return the computer
 * @throws AbortException in case of error.
 */
@Nonnull
private Computer getComputer() throws AbortException {
    if (computer != null) {
        return computer;
    }

    String node = null;
    Jenkins j = Jenkins.getActiveInstance();

    for (Computer c : j.getComputers()) {
        if (c.getChannel() == launcher.getChannel()) {
            node = c.getName();
            break;
        }
    }

    if (node == null) {
        throw new AbortException("Could not find computer for the job");
    }

    computer = j.getComputer(node);
    if (computer == null) {
        throw new AbortException("No such computer " + node);
    }

    if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.log(Level.FINE, "Computer: {0}", computer.getName());
        try {
            LOGGER.log(Level.FINE, "Env: {0}", computer.getEnvironment());
        } catch (IOException | InterruptedException e) {// ignored
        }
    }
    return computer;
}
项目:jenkins-parallels    文件:ParallelsDesktopCloud.java   
@Override
public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload)
{
    LOGGER.log(Level.SEVERE, "Going to provision " + excessWorkload + " executors");
    Collection<NodeProvisioner.PlannedNode> result = new ArrayList<NodeProvisioner.PlannedNode>();
    final ParallelsDesktopConnectorSlaveComputer connector = getConnector();
    for (int i = 0; (i < vms.size()) && (excessWorkload > 0); i++)
    {
        final ParallelsDesktopVM vm = vms.get(i);
        if (vm.isProvisioned())
            continue;
        if (!label.matches(Label.parse(vm.getLabels())))
            continue;
        final String vmId = vm.getVmid();
        final String slaveName = name + " " + vmId;
        vm.setSlaveName(slaveName);
        vm.setProvisioned(true);
        --excessWorkload;
        result.add(new NodeProvisioner.PlannedNode(slaveName,
            Computer.threadPoolForRemoting.submit(new Callable<Node>()
            {
                @Override
                public Node call() throws Exception
                {
                    connector.checkVmExists(vmId);
                    return connector.createSlaveOnVM(vm);
                }
            }), 1));
    }
    return result;
}
项目:openedge-jenkins-plugin    文件:OpenEdgeMatrixBuildWrapper.java   
@Override
public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
    String oeAxis = build.getEnvironment(listener).get("oeaxis");
    LOGGER.info("OpenEdge axis : " + oeAxis);

    OpenEdgeInstallation installation = getOpenEdgeInstallation(oeAxis);
    // This is executed on the master server, so we can't use getVersionNumber from the Node specific OpenEdgeInstallation
    // However, it should be expected to be in the same major version !
    final String majorVersion = installation.getVersionNumber();
    final String arch = installation.getArch();
    if (installation != null) {
        installation = installation.forNode(Computer.currentComputer().getNode(), listener);
    }

    // Add DLC variable and modify PATH
    final OpenEdgeInstallation install = installation;
    return new Environment() {
        @Override
        public void buildEnvVars(Map<String, String> env) {
            if (install != null) {
                EnvVars envVars = new EnvVars();
                install.buildEnvVars(envVars);
                envVars.put("OE_MAJOR_VERSION", majorVersion);
                envVars.put("OE_ARCH", arch);
                env.putAll(envVars);
            }
        }
    };
}
项目:jenkins-terraform-plugin    文件:TerraformBuildWrapper.java   
public String getExecutable(EnvVars env, BuildListener listener, Launcher launcher) throws IOException, InterruptedException {
    String executablePath = null;
    try {
        TerraformInstallation terraform = getInstallation().forNode(Computer.currentComputer().getNode(), listener).forEnvironment(env);
        executablePath = terraform.getExecutablePath(launcher);
    } catch (NullPointerException ex) {
        throw new IOException(Messages.InstallationNotFound());
    }
    return executablePath;
}
项目:ansible-plugin    文件:AnsibleAdHocCommandBuilder.java   
@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());
    }
}
项目:ansible-plugin    文件:AnsiblePlaybookBuilder.java   
@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));
}
项目:sumologic-jenkins-plugin    文件:ModelFactory.java   
public static JenkinsModel createJenkinsModel(Jenkins jenkins) {
  Queue queue = jenkins.getQueue();
  final Queue.Item[] items = queue.getItems();
  int queueLength = items.length;
  long maxwait = 0, averagewait = 0, now = System.currentTimeMillis();
  for(Queue.Item item : items){
    long waiting = now - item.getInQueueSince();
    maxwait = maxwait > waiting ? maxwait : waiting;
    averagewait += waiting;
  }
  if (queueLength > 0 ) {
    averagewait = averagewait / queueLength;
  }

  QueueModel queueModel = new QueueModel(queueLength,queueLength - queue.countBuildableItems(), maxwait, averagewait);

  int numFreeExecutors=0;

  for (Computer computer : jenkins.getComputers()) {
    if (computer.isOnline()){
      numFreeExecutors += computer.countIdle();
    }

  }
  SlaveModel slaveModel = new SlaveModel(jenkins.getComputers().length - 1, jenkins.getNumExecutors(), numFreeExecutors);

  return new JenkinsModel(queueModel, slaveModel, jenkins.getDescription());
}
项目:zaproxy-plugin    文件:ZAProxy.java   
/**
 * 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);
    }
}
项目:zaproxy-plugin    文件:ZAProxyBuilder.java   
/**
    * Replace macro with environment variable if it exists
    * @param build
    * @param listener
    * @param macro
    * @return
    * @throws InterruptedException
    */
   @SuppressWarnings({ "unchecked", "rawtypes" })
public static String applyMacro(AbstractBuild build, BuildListener listener, String macro)
           throws InterruptedException{
       try {
           EnvVars envVars = new EnvVars(Computer.currentComputer().getEnvironment());
           envVars.putAll(build.getEnvironment(listener));
           envVars.putAll(build.getBuildVariables());
           return Util.replaceMacro(macro, envVars);
       } catch (IOException e) {
        listener.getLogger().println("Failed to apply macro " + macro);
        listener.error(ExceptionUtils.getStackTrace(e));
       }
       return macro;
   }
项目:yet-another-docker-plugin    文件:JenkinsRuleHelpers.java   
/**
 * Returns true if Hudson is building something or going to build something.
 */
public static boolean isSomethingHappening(Jenkins jenkins) {
    if (!jenkins.getQueue().isEmpty())
        return true;
    for (Computer n : jenkins.getComputers())
        if (!n.isIdle())
            return true;
    return false;
}
项目:yet-another-docker-plugin    文件:DockerComputerListener.java   
@Override
public void onLaunchFailure(Computer comp, TaskListener taskListener) throws IOException, InterruptedException {
    if (comp instanceof DockerComputer) {
        DockerComputer dockerComputer = (DockerComputer) comp;
        if (dockerComputer.getLauncher() instanceof DockerComputerIOLauncher) {
            taskListener.error("Failed to launch");
        }
    }
}
项目:testdroid-marionette-plugin    文件:DeviceSessionWrapper.java   
/**
 * Replace macro with environment variable if it exists
 * @param build
 * @param listener
 * @param macro
 * @return
 * @throws InterruptedException
 */
public static String applyMacro(AbstractBuild build, BuildListener listener, String macro)
        throws InterruptedException{
    try {
        EnvVars envVars = new EnvVars(Computer.currentComputer().getEnvironment());
        envVars.putAll(build.getEnvironment(listener));
        envVars.putAll(build.getBuildVariables());
        return Util.replaceMacro(macro, envVars);
    } catch (IOException e) {
        LOGGER.log(Level.SEVERE, "Failed to apply macro " + macro, e);
    }
    return macro;
}
项目:deployer-framework-plugin    文件:DeployNowTask.java   
public CauseOfBlockage getCauseOfBlockage() {
    if (System.currentTimeMillis() > nextCheckForNode) {
        nextCheckForNode = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(60);
        Computer.threadPoolForRemoting.submit(new Runnable() {
            public void run() {
                DeployNowSlave.ensurePresent();
            }
        });
    }
    return null;
}
项目:deployer-framework-plugin    文件:DeployNowComputer.java   
private void checkLater() {
    Computer.threadPoolForRemoting.submit(new Runnable() {
        public void run() {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                // ignore
            }
            RETENTION_STRATEGY.check(DeployNowComputer.this);
        }
    });
}