本文整理汇总了Java中com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl.getId方法的典型用法代码示例。如果您正苦于以下问题:Java UsernamePasswordCredentialsImpl.getId方法的具体用法?Java UsernamePasswordCredentialsImpl.getId怎么用?Java UsernamePasswordCredentialsImpl.getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl
的用法示例。
在下文中一共展示了UsernamePasswordCredentialsImpl.getId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldRetrieveOverridingCredentialFromProject
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl; //导入方法依赖的package包/类
@Test
public void shouldRetrieveOverridingCredentialFromProject() throws Exception {
Folder f = r.jenkins.createProject(Folder.class, "folder1");
UsernamePasswordCredentialsImpl credentials =
new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, ID, DESCRIPTION, USERNAME,
PASSWORD);
getFolderStore(f).addCredentials(Domain.global(), credentials);
// Matches what's sent from ui
Credential overridingCredentialProvided = new Credential(null, "", null, credentials.getId(), null, true);
DeployitNotifier.DeployitDescriptor descriptor = new DeployitNotifier.DeployitDescriptor();
DeployitNotifier notifierSpy = spy(new DeployitNotifier("AdminGlobal1", "app1", null, null, null, null, false, null, overridingCredentialProvided));
doReturn(descriptor).when(notifierSpy).getDescriptor();
doReturn(overridingCredentialProvided).when(notifierSpy).getOverridingCredential();
FreeStyleProject freeStyleProjectSpy = spy(new FreeStyleProject(f, "folder1/proj1"));
freeStyleProjectSpy.addPublisher(notifierSpy);
DescribableList<Publisher, Descriptor<Publisher>> publisherListMock = mock(DescribableList.class);
doReturn(notifierSpy).when(publisherListMock).get(any(DeployitNotifier.DeployitDescriptor.class));
doReturn(publisherListMock).when(freeStyleProjectSpy).getPublishersList();
Credential overridingCredential = RepositoryUtils.retrieveOverridingCredentialFromProject(freeStyleProjectSpy);
assertEquals(USERNAME, overridingCredential.getUsername());
assertEquals(PASSWORD, overridingCredential.getPassword().getPlainText());
}
示例2: testDockerShellStep
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl; //导入方法依赖的package包/类
@Test
public void testDockerShellStep() throws Throwable {
jRule.getInstance().setNumExecutors(0);
// jRule.createSlave();
// jRule.createSlave("my-slave", "remote-slave", new EnvVars());
final UsernamePasswordCredentialsImpl credentials = new UsernamePasswordCredentialsImpl(CredentialsScope.SYSTEM,
null, "description", "vagrant", "vagrant");
CredentialsStore store = CredentialsProvider.lookupStores(jRule.getInstance()).iterator().next();
store.addCredentials(Domain.global(), credentials);
final SSHLauncher sshLauncher = new SSHLauncher("192.168.33.10", 22, credentials.getId(),
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", //jvmopts
"", // String javaPath,
"", // String prefixStartSlaveCmd,
"", // String suffixStartSlaveCmd,
20, // Integer launchTimeoutSeconds,
1, // Integer maxNumRetries,
3// Integer retryWaitTime
);
final DumbSlave dumbSlave = new DumbSlave("docker-daemon", "/home/vagrant/jenkins2", sshLauncher);
jRule.getInstance().addNode(dumbSlave);
await().timeout(60, SECONDS).until(() -> assertThat(dumbSlave.getChannel(), notNullValue()));
// String dockerfilePath = dumbSlave.getChannel().call(new DockerBuildImageStepTest.StringThrowableCallable());
final CredentialsYADockerConnector dockerConnector = new CredentialsYADockerConnector()
.withConnectorType(JERSEY)
.withServerUrl("tcp://127.0.0.1:2376")
.withSslConfig(new LocalDirectorySSLConfig("/home/vagrant/keys"));
// .withCredentials(new DockerDaemonFileCredentials(null, "docker-cert", "",
// "/home/vagrant/keys"));
DockerShellStep dockerShellStep = new DockerShellStep();
dockerShellStep.setShellScript("env && pwd");
dockerShellStep.setConnector(dockerConnector);
FreeStyleProject project = jRule.createFreeStyleProject("test");
project.getBuildersList().add(dockerShellStep);
project.save();
QueueTaskFuture<FreeStyleBuild> taskFuture = project.scheduleBuild2(0);
FreeStyleBuild freeStyleBuild = taskFuture.get();
jRule.waitForCompletion(freeStyleBuild);
jRule.assertBuildStatusSuccess(freeStyleBuild);
}
示例3: testComboBuild
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl; //导入方法依赖的package包/类
@Ignore
@Test
public void testComboBuild() throws Throwable {
jRule.getInstance().setNumExecutors(0);
// jRule.createSlave();
// jRule.createSlave("my-slave", "remote-slave", new EnvVars());
final UsernamePasswordCredentialsImpl credentials = new UsernamePasswordCredentialsImpl(CredentialsScope.SYSTEM,
null, "description", "vagrant", "vagrant");
CredentialsStore store = CredentialsProvider.lookupStores(jRule.getInstance()).iterator().next();
store.addCredentials(Domain.global(), credentials);
final SSHLauncher sshLauncher = new SSHLauncher("192.168.33.10", 22, credentials.getId(),
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", //jvmopts
"", // String javaPath,
"", // String prefixStartSlaveCmd,
"", // String suffixStartSlaveCmd,
20, // Integer launchTimeoutSeconds,
1, // Integer maxNumRetries,
3// Integer retryWaitTime
);
final DumbSlave dumbSlave = new DumbSlave("docker-daemon", "/home/vagrant/jenkins2", sshLauncher);
jRule.getInstance().addNode(dumbSlave);
await().timeout(60, SECONDS).until(() -> assertThat(dumbSlave.getChannel(), notNullValue()));
String dockerfilePath = dumbSlave.getChannel().call(new StringThrowableCallable());
final CredentialsYADockerConnector dockerConnector = new CredentialsYADockerConnector()
.withConnectorType(JERSEY)
.withServerUrl("tcp://127.0.0.1:2376")
.withSslConfig(new LocalDirectorySSLConfig("/home/vagrant/keys"));
// .withCredentials(new DockerDaemonFileCredentials(null, "docker-cert", "",
// "/home/vagrant/keys"));
DockerBuildImage buildImage = new DockerBuildImage();
buildImage.setBaseDirectory(dockerfilePath);
buildImage.setPull(true);
buildImage.setTags(Collections.singletonList("localhost:5000/myfirstimage"));
DockerImageComboStep comboStep = new DockerImageComboStep(dockerConnector, buildImage);
comboStep.setClean(true);
comboStep.setPush(true);
FreeStyleProject project = jRule.createFreeStyleProject("test");
project.getBuildersList().add(comboStep);
project.save();
QueueTaskFuture<FreeStyleBuild> taskFuture = project.scheduleBuild2(0);
FreeStyleBuild freeStyleBuild = taskFuture.get();
jRule.waitForCompletion(freeStyleBuild);
jRule.assertBuildStatusSuccess(freeStyleBuild);
}
示例4: testBuild
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl; //导入方法依赖的package包/类
@Test
public void testBuild() throws Throwable {
jRule.getInstance().setNumExecutors(0);
// jRule.createSlave();
// jRule.createSlave("my-slave", "remote-slave", new EnvVars());
final UsernamePasswordCredentialsImpl credentials = new UsernamePasswordCredentialsImpl(CredentialsScope.SYSTEM,
null, "description", "vagrant", "vagrant");
CredentialsStore store = CredentialsProvider.lookupStores(jRule.getInstance()).iterator().next();
store.addCredentials(Domain.global(), credentials);
final SSHLauncher sshLauncher = new SSHLauncher("192.168.33.10", 22, credentials.getId(),
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", //jvmopts
"", // String javaPath,
"", // String prefixStartSlaveCmd,
"", // String suffixStartSlaveCmd,
20, // Integer launchTimeoutSeconds,
1, // Integer maxNumRetries,
3// Integer retryWaitTime
);
final DumbSlave dumbSlave = new DumbSlave("docker-daemon", "/home/vagrant/jenkins2", sshLauncher);
jRule.getInstance().addNode(dumbSlave);
await().timeout(60, SECONDS).until(() -> assertThat(dumbSlave.getChannel(), notNullValue()));
String dockerfilePath = dumbSlave.getChannel().call(new StringThrowableCallable());
final CredentialsYADockerConnector dockerConnector = new CredentialsYADockerConnector()
.withConnectorType(JERSEY)
.withServerUrl("tcp://127.0.0.1:2376")
.withSslConfig(new LocalDirectorySSLConfig("/home/vagrant/keys"));
// .withCredentials(new DockerDaemonFileCredentials(null, "docker-cert", "",
// "/home/vagrant/keys"));
DockerBuildImage buildImage = new DockerBuildImage();
buildImage.setBaseDirectory(dockerfilePath);
buildImage.setPull(true);
DockerBuildImageStep dockerBuildImageStep = new DockerBuildImageStep(dockerConnector, buildImage);
FreeStyleProject project = jRule.createFreeStyleProject("test");
project.getBuildersList().add(dockerBuildImageStep);
project.save();
QueueTaskFuture<FreeStyleBuild> taskFuture = project.scheduleBuild2(0);
FreeStyleBuild freeStyleBuild = taskFuture.get();
jRule.waitForCompletion(freeStyleBuild);
jRule.assertBuildStatusSuccess(freeStyleBuild);
}