Skip to content

Commit e2c0289

Browse files
authored
Merge pull request #338 from jglick/agentDockerWithCreds
Skip `agentDockerWithCreds` unless both `docker.username` and `docker.password` are set
2 parents 76126c7 + 15b2c25 commit e2c0289

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/test/java/org/jenkinsci/plugins/docker/workflow/declarative/DockerAgentTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.jenkinsci.plugins.docker.workflow.DockerTestUtil;
4040
import org.jenkinsci.plugins.pipeline.modeldefinition.AbstractModelDefTest;
4141
import static org.jenkinsci.plugins.pipeline.modeldefinition.AbstractModelDefTest.j;
42+
import static org.junit.Assume.assumeTrue;
4243
import org.junit.BeforeClass;
4344
import org.junit.Ignore;
4445
import 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

Comments
 (0)