Java Code Examples for hudson.model.Executor#getOwner()

The following examples show how to use hudson.model.Executor#getOwner() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContainerRecordUtils.java    From yet-another-docker-plugin with MIT License 6 votes vote down vote up
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);
        }
    }


}
 
Example 2
Source File: DockerOnceRetentionStrategy.java    From yet-another-docker-plugin with MIT License 6 votes vote down vote up
protected void done(Executor executor) {
    final AbstractCloudComputer<?> c = (AbstractCloudComputer) executor.getOwner();
    Queue.Executable exec = executor.getCurrentExecutable();
    if (executor instanceof OneOffExecutor) {
        LOG.debug("Not terminating {} because {} was a flyweight task", c.getName(), exec);
        return;
    }

    if (exec instanceof ContinuableExecutable && ((ContinuableExecutable) exec).willContinue()) {
        LOG.debug("not terminating {} because {} says it will be continued", c.getName(), exec);
        return;
    }

    LOG.debug("terminating {} since {} seems to be finished", c.getName(), exec);
    done(c);
}
 
Example 3
Source File: DockerSwarmAgentRetentionStrategy.java    From docker-swarm-plugin with MIT License 5 votes vote down vote up
private void done(Executor executor) {
    final DockerSwarmComputer c = (DockerSwarmComputer) executor.getOwner();
    Queue.Executable exec = executor.getCurrentExecutable();
    if (exec instanceof ContinuableExecutable && ((ContinuableExecutable) exec).willContinue()) {
        LOGGER.log(Level.FINE, "not terminating {0} because {1} says it will be continued",
                new Object[] { c.getName(), exec });
        return;
    }
    LOGGER.log(Level.FINE, "terminating {0} since {1} seems to be finished", new Object[] { c.getName(), exec });
    done(c);
}
 
Example 4
Source File: DockerOnceRetentionStrategy.java    From docker-plugin with MIT License 5 votes vote down vote up
private void done(Executor executor) {
    final DockerComputer c = (DockerComputer) executor.getOwner();
    Queue.Executable exec = executor.getCurrentExecutable();
    if (exec instanceof ContinuableExecutable && ((ContinuableExecutable) exec).willContinue()) {
        LOGGER.log(Level.FINE, "not terminating {0} because {1} says it will be continued", new Object[]{c.getName(), exec});
        return;
    }
    LOGGER.log(Level.FINE, "terminating {0} since {1} seems to be finished", new Object[]{c.getName(), exec});
    done(c);
}
 
Example 5
Source File: DockerSwarmAgentRetentionStrategy.java    From docker-swarm-plugin with MIT License 4 votes vote down vote up
private PrintStream getLogger(Executor executor) {
    final DockerSwarmComputer c = (DockerSwarmComputer) executor.getOwner();
    return c.getListener().getLogger();
}
 
Example 6
Source File: DockerEnvironmentContributor.java    From yet-another-docker-plugin with MIT License 4 votes vote down vote up
@Override
public void buildEnvironmentFor(@Nonnull Run run, @Nonnull EnvVars envs, @Nonnull TaskListener listener)
        throws IOException, InterruptedException {
    final Executor executor = run.getExecutor();
    if (executor != null && executor.getOwner() instanceof DockerComputer) {
        final DockerComputer dockerComputer = (DockerComputer) executor.getOwner();
        DockerSlave node = dockerComputer.getNode();
        if (isNull(node)) {
            LOG.debug("{} is missing it's node, skipping...", dockerComputer.getName());
            return;
        }

        final DockerNodeProperty dProp = node.getNodeProperties().get(DockerNodeProperty.class);
        if (dProp == null) {
            return;
        }

        if (dProp.isContainerIdCheck()) {
            listener.getLogger().println("[YAD-PLUGIN] Injecting variable: " + dProp.getContainerId());
            envs.put(dProp.getContainerId(), dockerComputer.getContainerId());
        }

        if (dProp.isCloudIdCheck()) {
            listener.getLogger().println("[YAD-PLUGIN] Injecting variable: " + dProp.getCloudId());
            envs.put(dProp.getCloudId(), dockerComputer.getCloudId());
        }

        if (dProp.isDockerHostCheck()) {
            try {
                //replace http:// and https:// from docker-java to tcp://
                final DockerCloud cloud = dockerComputer.getCloud(); // checkfornull
                if (cloud != null && cloud.getConnector() != null) {
                    final URIBuilder uriBuilder = new URIBuilder(cloud.getConnector().getServerUrl());
                    if (!uriBuilder.getScheme().equals("unix")) {
                        uriBuilder.setScheme("tcp");
                    }

                    listener.getLogger().println("[YAD-PLUGIN] Injecting variable: " + dProp.getDockerHost());
                    envs.put(dProp.getDockerHost(), uriBuilder.toString());
                }
            } catch (URISyntaxException e) {
                listener.error("Can't make variable: %s", dProp.getDockerHost(), e);
                LOG.error("Can't make '{}' variable: {}", dProp.getDockerHost(), e);
            }
        }
    }
}