2525package org .jenkinsci .plugins .docker .workflow .declarative ;
2626
2727import com .cloudbees .hudson .plugins .folder .Folder ;
28- import com .cloudbees .plugins .credentials .CredentialsProvider ;
29- import com .cloudbees .plugins .credentials .CredentialsScope ;
30- import com .cloudbees .plugins .credentials .CredentialsStore ;
31- import com .cloudbees .plugins .credentials .domains .Domain ;
32- import com .cloudbees .plugins .credentials .impl .UsernamePasswordCredentialsImpl ;
3328import hudson .model .Result ;
3429import hudson .model .Slave ;
3530import hudson .slaves .EnvironmentVariablesNodeProperty ;
3934import org .jenkinsci .plugins .docker .workflow .DockerTestUtil ;
4035import org .jenkinsci .plugins .pipeline .modeldefinition .AbstractModelDefTest ;
4136import static org .jenkinsci .plugins .pipeline .modeldefinition .AbstractModelDefTest .j ;
42- import static org .junit .Assume .assumeTrue ;
4337import org .junit .BeforeClass ;
4438import org .junit .Ignore ;
4539import org .junit .Test ;
@@ -53,7 +47,6 @@ public class DockerAgentTest extends AbstractModelDefTest {
5347 private static Slave s ;
5448 private static Slave s2 ;
5549
56- private static String username , password ;
5750 @ BeforeClass
5851 public static void setUpAgent () throws Exception {
5952 s = j .createOnlineSlave ();
@@ -66,32 +59,14 @@ public static void setUpAgent() throws Exception {
6659 s2 .setLabelString ("other-docker" );
6760 s2 .getNodeProperties ().add (new EnvironmentVariablesNodeProperty (new EnvironmentVariablesNodeProperty .Entry ("ONAGENT" , "true" ),
6861 new EnvironmentVariablesNodeProperty .Entry ("WHICH_AGENT" , "second" )));
69- //setup credentials for docker registry
70- CredentialsStore store = CredentialsProvider .lookupStores (j .jenkins ).iterator ().next ();
71-
72- username = System .getProperty ("docker.username" );
73- password = System .getProperty ("docker.password" );
74-
75- if (username != null && password != null ) {
76- UsernamePasswordCredentialsImpl globalCred =
77- new UsernamePasswordCredentialsImpl (CredentialsScope .GLOBAL ,
78- "dockerhub" , "real" , username , password );
79-
80- store .addCredentials (Domain .global (), globalCred );
81-
82- }
8362 }
8463
8564 @ Test
8665 public void agentDocker () throws Exception {
8766 agentDocker ("org/jenkinsci/plugins/docker/workflow/declarative/agentDocker" , "-v /tmp:/tmp" );
8867 }
8968
90- @ Test
91- public void agentDockerWithCreds () throws Exception {
92- assumeTrue (username != null && password != null );
93- agentDocker ("org/jenkinsci/plugins/docker/workflow/declarative/agentDockerWithCreds" , "-v /tmp:/tmp" );
94- }
69+ // TODO write test of registryCredentialsId, e.g. using a registry in Testcontainers, or MockLauncherStep as in RegistryEndpointStepTest
9570
9671 @ Test
9772 public void agentDockerWithRegistryNoCreds () throws Exception {
0 commit comments