public Node call() throws Exception { // simulate the delay in provisioning a new slave, // since it's normally some async operation. Thread.sleep(time); System.out.println("launching slave"); final DumbSlave slave = rule.createSlave(label); for (NodeProperty nodeProperty : nodeProperties) { slave.getNodeProperties().add(updateWithNode(nodeProperty, slave)); } computer = slave.toComputer(); computer.connect(false).get(); synchronized (DummyCloudImpl.this) { System.out.println(computer.getName()+" launch"+(computer.isOnline()?"ed successfully":" failed")); System.out.println(computer.getLog()); } return slave; } }
@BeforeClass public static void setUpAgentAndCreds() throws Exception { s = j.createOnlineSlave(); s.setLabelString("some-label docker here"); s.getNodeProperties().add(new EnvironmentVariablesNodeProperty(new EnvironmentVariablesNodeProperty.Entry("ONAGENT", "true"), new EnvironmentVariablesNodeProperty.Entry("WHICH_AGENT", "first"))); s.setNumExecutors(2); s2 = j.createOnlineSlave(); s2.setLabelString("other-docker"); s2.getNodeProperties().add(new EnvironmentVariablesNodeProperty(new EnvironmentVariablesNodeProperty.Entry("ONAGENT", "true"), new EnvironmentVariablesNodeProperty.Entry("WHICH_AGENT", "second"))); CredentialsStore store = CredentialsProvider.lookupStores(j.jenkins).iterator().next(); String usernamePasswordCredentialsId = "FOOcredentials"; UsernamePasswordCredentialsImpl usernamePassword = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, usernamePasswordCredentialsId, "sample", usernamePasswordUsername, usernamePasswordPassword); store.addCredentials(Domain.global(), usernamePassword); }
DumbSlave s = story.j.createOnlineSlave(); s.setLabelString("remote quick"); s.getNodeProperties().add(new EnvironmentVariablesNodeProperty(new EnvironmentVariablesNodeProperty.Entry("ONAGENT", "true")));