25
25
package org .jenkinsci .plugins .docker .workflow .declarative ;
26
26
27
27
import 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 ;
33
28
import hudson .model .Result ;
34
29
import hudson .model .Slave ;
35
30
import hudson .slaves .EnvironmentVariablesNodeProperty ;
39
34
import org .jenkinsci .plugins .docker .workflow .DockerTestUtil ;
40
35
import org .jenkinsci .plugins .pipeline .modeldefinition .AbstractModelDefTest ;
41
36
import static org .jenkinsci .plugins .pipeline .modeldefinition .AbstractModelDefTest .j ;
42
- import static org .junit .Assume .assumeTrue ;
43
37
import org .junit .BeforeClass ;
44
38
import org .junit .Ignore ;
45
39
import org .junit .Test ;
@@ -53,7 +47,6 @@ public class DockerAgentTest extends AbstractModelDefTest {
53
47
private static Slave s ;
54
48
private static Slave s2 ;
55
49
56
- private static String username , password ;
57
50
@ BeforeClass
58
51
public static void setUpAgent () throws Exception {
59
52
s = j .createOnlineSlave ();
@@ -66,32 +59,14 @@ public static void setUpAgent() throws Exception {
66
59
s2 .setLabelString ("other-docker" );
67
60
s2 .getNodeProperties ().add (new EnvironmentVariablesNodeProperty (new EnvironmentVariablesNodeProperty .Entry ("ONAGENT" , "true" ),
68
61
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
- }
83
62
}
84
63
85
64
@ Test
86
65
public void agentDocker () throws Exception {
87
66
agentDocker ("org/jenkinsci/plugins/docker/workflow/declarative/agentDocker" , "-v /tmp:/tmp" );
88
67
}
89
68
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
95
70
96
71
@ Test
97
72
public void agentDockerWithRegistryNoCreds () throws Exception {
0 commit comments