当前位置: 首页>>代码示例>>Java>>正文


Java Slave类代码示例

本文整理汇总了Java中hudson.model.Slave的典型用法代码示例。如果您正苦于以下问题:Java Slave类的具体用法?Java Slave怎么用?Java Slave使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Slave类属于hudson.model包,在下文中一共展示了Slave类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copySlaveJarUsingSCP

import hudson.model.Slave; //导入依赖的package包/类
/**
 * Method copies the slave jar to the remote system using scp.
 *
 * @param listener         The listener.
 * @param workingDirectory The directory into which the slave jar will be copied.
 * @throws IOException          If something goes wrong.
 * @throws InterruptedException If something goes wrong.
 */
private void copySlaveJarUsingSCP(TaskListener listener, String workingDirectory) throws IOException, InterruptedException {
    SCPClient scp = new SCPClient(connection);
    try {
        // check if the working directory exists
        if (connection.exec("test -d " + workingDirectory, listener.getLogger()) != 0) {
            listener.getLogger().println("Remote filesystem doesn't exist");
            // working directory doesn't exist, lets make it.
            if (connection.exec("mkdir -p " + workingDirectory, listener.getLogger()) != 0) {
                listener.getLogger().println("Failed to create " + workingDirectory);
            }
        }

        // delete the slave jar as we do with SFTP
        connection.exec("rm " + workingDirectory + "/slave.jar", new NullStream());

        // SCP it to the slave. hudson.Util.ByteArrayOutputStream2 doesn't work for this. It pads the byte array.
        listener.getLogger().println("Copying slave jar");
        scp.put(new Slave.JnlpJar("slave.jar").readFully(), "slave.jar", workingDirectory, "0644");
    } catch (IOException e) {
        throw new IOException2("Error copying slave jar", e);
    }
}
 
开发者ID:thescouser89,项目名称:ovirt-slaves-plugin,代码行数:31,代码来源:OVirtSshLauncher.java

示例2: getFakeSlave

import hudson.model.Slave; //导入依赖的package包/类
protected Slave getFakeSlave(JenkinsRule r) throws Exception {
    PretendSlave slave = r.createPretendSlave(p -> {
        if (p.cmds().get(0).equals(KUBECTL_BINARY)) {
            String[] maskedCmd = getMaskedCmd(p.cmds(), p.masks());
            PrintStream ps = new PrintStream(p.stdout());
            ps.println("Call stubbed for: " + String.join(", ", maskedCmd));
            return new FakeLauncher.FinishedProc(0);
        }
        return r.createLocalLauncher().launch(p);
    });
    slave.setLabelString("mocked-kubectl");
    return slave;
}
 
开发者ID:maxlaverse,项目名称:kubernetes-cli-plugin,代码行数:14,代码来源:KubectlTestBase.java

示例3: createSpecialEnvSlave

import hudson.model.Slave; //导入依赖的package包/类
/**
 * Akin to {@link JenkinsRule#createSlave(String, String, EnvVars)} but allows {@link Computer#getEnvironment} to be controlled rather than directly modifying launchers.
 * @param env variables to override in {@link Computer#getEnvironment}; null values will get unset even if defined in the test environment
 * @see <a href="https://github.com/jenkinsci/jenkins/pull/1553/files#r23784822">explanation in core PR 1553</a>
 */
public static Slave createSpecialEnvSlave(JenkinsRule rule, String nodeName, @CheckForNull String labels, Map<String,String> env) throws Exception {
    @SuppressWarnings("deprecation") // keep consistency with original signature rather than force the caller to pass in a TemporaryFolder rule
    File remoteFS = rule.createTmpDir();
    SpecialEnvSlave slave = new SpecialEnvSlave(remoteFS, rule.createComputerLauncher(/* yes null */null), nodeName, labels != null ? labels : "", env);
    rule.jenkins.addNode(slave);
    return slave;
}
 
开发者ID:10000TB,项目名称:Jenkins-Plugin-Examples,代码行数:13,代码来源:CoreWrapperStepTest.java

示例4: executeCheck

import hudson.model.Slave; //导入依赖的package包/类
public boolean executeCheck(Node item) {
    try {
        LOG.log(Level.INFO, "slave " + item.getDisplayName() + " service " +  ( (Slave) item).getComputer().getLauncher().toString());
        return ((Slave) item).getComputer().getLauncher().toString().contains("ManagedWindowsServiceLauncher");
    } catch (NullPointerException npe) {
        return false;
    }
}
 
开发者ID:v1v,项目名称:jenkinslint-plugin,代码行数:9,代码来源:WindowsSlaveLaunchChecker.java

示例5: afterContainerCreate

import hudson.model.Slave; //导入依赖的package包/类
@Override
    public void afterContainerCreate(DockerClient client, String containerId) throws IOException {
        // upload archive
        try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
             TarArchiveOutputStream tarOut = new TarArchiveOutputStream(byteArrayOutputStream)) {

            // @see hudson.model.Slave.JnlpJar.getURL()
//            byte[] slavejar = IOUtils.toByteArray(Jenkins.getInstance().servletContext.getResourceAsStream("/WEB-INF/slave.jar"));
//            if (isNull(null)) {
//                // during the development this path doesn't have the files.
//                slavejar = Files.readAllBytes(Paths.get("./target/jenkins/WEB-INF/slave.jar"));
//            }
            byte[] slaveJar = new Slave.JnlpJar("slave.jar").readFully();

            TarArchiveEntry entry = new TarArchiveEntry("slave.jar");
            entry.setSize(slaveJar.length);
            entry.setMode(0664);
            tarOut.putArchiveEntry(entry);
            tarOut.write(slaveJar);
            tarOut.closeArchiveEntry();


            tarOut.close();
            try (InputStream is = new ByteArrayInputStream(byteArrayOutputStream.toByteArray())) {
                client.copyArchiveToContainerCmd(containerId)
                        .withTarInputStream(is)
                        .withRemotePath("/tmp")
                        .exec();
            }
        }
    }
 
开发者ID:KostyaSha,项目名称:yet-another-docker-plugin,代码行数:32,代码来源:DockerComputerIOLauncher.java

示例6: check

import hudson.model.Slave; //导入依赖的package包/类
@Override
public synchronized long check(final DeployNowComputer c) {
    if (!c.isIdle()) {
        return 1;
    }
    final Jenkins jenkins = Jenkins.getInstance();
    if (jenkins != null) {
        for (Queue.Item t : jenkins.getQueue().getItems()) {
            if (t.task instanceof DeployNowTask) {
                return 1;
            }
        }
    }
    if (!c.offline) {
        c.offline = true;
        try {
            if (jenkins != null) {
                Slave node = c.getNode();
                if (node != null) {
                    jenkins.removeNode(node);
                }
            }
        } catch (IOException e) {
            // ignore
        }
    }
    return 1;
}
 
开发者ID:jenkinsci,项目名称:deployer-framework-plugin,代码行数:29,代码来源:DeployNowComputer.java

示例7: getSepFor

import hudson.model.Slave; //导入依赖的package包/类
/**
 * Returns the separator for that node -- if possible to be retrieved.
 * <p>
 * Guaranteed to always be either "/", "\\" or null.
 * <p>
 * The result is cached, so that repeated lookups are sped-up and
 * random node offlining does not affect the separator calculation as much.
 * 
 * @param n the node to check.
 * @return the separator, one of "/", "\\" or null.
 */
public String getSepFor(Node n) {
	if (n == null) { return null; }
	//Check if a value is cached
	String c = nodeLookup.getIfPresent(n);
	if (c != null) { return c; }
	
	try {
		//Check if the node is online and we can determine the separator via
		//a system property
		c = this.getRawSepFor(n.toComputer());
		if (c != null) { return c; }
		
		//Check if the remote root path can tell us something
		if (n instanceof Slave) {
			c = this.getRawSepFor((Slave)n);
			if (c != null) { return c; }
		}
		
		//Last fallback, try to determine based on full file path
		c = this.getRawSepFor(n.getRootPath());
		if (c != null) { return c; }
	} finally {
		if (c != null) {
			nodeLookup.put(n, c);
		}
	}
	//If this point is reached, no path could be found
	return null;
}
 
开发者ID:i-m-c,项目名称:jenkins-inheritance-plugin,代码行数:41,代码来源:NodeFileSeparator.java

示例8: FleetNodeComputer

import hudson.model.Slave; //导入依赖的package包/类
public FleetNodeComputer(final Slave slave) {
    super(slave);
}
 
开发者ID:awslabs,项目名称:ec2-spot-jenkins-plugin,代码行数:4,代码来源:FleetNodeComputer.java

示例9: testDefaultSlave

import hudson.model.Slave; //导入依赖的package包/类
@Test public void testDefaultSlave() throws Exception {
    Slave slave = createLinuxSlave("default", "", "");
    assertFalse(checker.executeCheck(slave));
}
 
开发者ID:v1v,项目名称:jenkinslint-plugin,代码行数:5,代码来源:WindowsSlaveLaunchCheckerTestCase.java

示例10: testWindowsSlave

import hudson.model.Slave; //导入依赖的package包/类
@Test public void testWindowsSlave() throws Exception {
    Slave slave = createWindowsSlave("default", "", "somelabel");
    assertFalse(checker.executeCheck(slave));
}
 
开发者ID:v1v,项目名称:jenkinslint-plugin,代码行数:5,代码来源:WindowsSlaveLaunchCheckerTestCase.java

示例11: testControlComment

import hudson.model.Slave; //导入依赖的package包/类
@Test public void testControlComment() throws Exception {
    Slave slave = createLinuxSlave("default", "", "");
    assertFalse(checker.isIgnored(slave.getNodeDescription()));
    slave = createLinuxSlave("default", "#lint:ignore:" + checker.getClass().getSimpleName(), "");
    assertTrue(checker.isIgnored(slave.getNodeDescription()));
}
 
开发者ID:v1v,项目名称:jenkinslint-plugin,代码行数:7,代码来源:WindowsSlaveLaunchCheckerTestCase.java

示例12: createLinuxSlave

import hudson.model.Slave; //导入依赖的package包/类
private Slave createLinuxSlave(String name, String description, String label) throws Exception {
    return new DumbSlave(name, description, "/wherever", "1", Node.Mode.NORMAL, label, new JNLPLauncher(), RetentionStrategy.NOOP, Collections.<NodeProperty<?>>emptyList());
}
 
开发者ID:v1v,项目名称:jenkinslint-plugin,代码行数:4,代码来源:WindowsSlaveLaunchCheckerTestCase.java

示例13: createWindowsSlave

import hudson.model.Slave; //导入依赖的package包/类
private Slave createWindowsSlave(String name, String description, String label) throws Exception {
    return new DumbSlave(name, description, "/wherever", "1", Node.Mode.NORMAL, label, new ManagedWindowsServiceLauncher("user", "pass"), RetentionStrategy.NOOP, Collections.<NodeProperty<?>>emptyList());
}
 
开发者ID:v1v,项目名称:jenkinslint-plugin,代码行数:4,代码来源:WindowsSlaveLaunchCheckerTestCase.java

示例14: testDefaultSlave

import hudson.model.Slave; //导入依赖的package包/类
@Test public void testDefaultSlave() throws Exception {
    Slave slave = createSlave("default", "", "");
    assertFalse(checker.executeCheck(slave));
}
 
开发者ID:v1v,项目名称:jenkinslint-plugin,代码行数:5,代码来源:SlaveVersionCheckerTestCase.java

示例15: testControlComment

import hudson.model.Slave; //导入依赖的package包/类
@Test public void testControlComment() throws Exception {
    Slave slave = createSlave("default", "", "");
    assertFalse(checker.isIgnored(slave.getNodeDescription()));
    slave = createSlave("default", "#lint:ignore:" + checker.getClass().getSimpleName(), "");
    assertTrue(checker.isIgnored(slave.getNodeDescription()));
}
 
开发者ID:v1v,项目名称:jenkinslint-plugin,代码行数:7,代码来源:SlaveVersionCheckerTestCase.java


注:本文中的hudson.model.Slave类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。