3939import org .jenkinsci .plugins .docker .workflow .DockerTestUtil ;
4040import org .jenkinsci .plugins .pipeline .modeldefinition .AbstractModelDefTest ;
4141import static org .jenkinsci .plugins .pipeline .modeldefinition .AbstractModelDefTest .j ;
42+ import static org .junit .Assume .assumeTrue ;
4243import org .junit .BeforeClass ;
4344import org .junit .Ignore ;
4445import org .junit .Test ;
@@ -52,7 +53,7 @@ public class DockerAgentTest extends AbstractModelDefTest {
5253 private static Slave s ;
5354 private static Slave s2 ;
5455
55- private static String password ;
56+ private static String username , password ;
5657 @ BeforeClass
5758 public static void setUpAgent () throws Exception {
5859 s = j .createOnlineSlave ();
@@ -68,12 +69,13 @@ public static void setUpAgent() throws Exception {
6869 //setup credentials for docker registry
6970 CredentialsStore store = CredentialsProvider .lookupStores (j .jenkins ).iterator ().next ();
7071
72+ username = System .getProperty ("docker.username" );
7173 password = System .getProperty ("docker.password" );
7274
73- if ( password != null ) {
75+ if ( username != null && password != null ) {
7476 UsernamePasswordCredentialsImpl globalCred =
7577 new UsernamePasswordCredentialsImpl (CredentialsScope .GLOBAL ,
76- "dockerhub" , "real" , "jtaboada" , password );
78+ "dockerhub" , "real" , username , password );
7779
7880 store .addCredentials (Domain .global (), globalCred );
7981
@@ -87,9 +89,8 @@ public void agentDocker() throws Exception {
8789
8890 @ Test
8991 public void agentDockerWithCreds () throws Exception {
90- //If there is no password, the test is ignored
91- if (password != null )
92- agentDocker ("org/jenkinsci/plugins/docker/workflow/declarative/agentDockerWithCreds" , "-v /tmp:/tmp" );
92+ assumeTrue (username != null && password != null );
93+ agentDocker ("org/jenkinsci/plugins/docker/workflow/declarative/agentDockerWithCreds" , "-v /tmp:/tmp" );
9394 }
9495
9596 @ Test
0 commit comments