Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.jenkinsci.plugins.docker.workflow.DockerTestUtil;
import org.jenkinsci.plugins.pipeline.modeldefinition.AbstractModelDefTest;
import static org.jenkinsci.plugins.pipeline.modeldefinition.AbstractModelDefTest.j;
import static org.junit.Assume.assumeTrue;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
Expand All @@ -52,7 +53,7 @@ public class DockerAgentTest extends AbstractModelDefTest {
private static Slave s;
private static Slave s2;

private static String password;
private static String username, password;
@BeforeClass
public static void setUpAgent() throws Exception {
s = j.createOnlineSlave();
Expand All @@ -68,12 +69,13 @@ public static void setUpAgent() throws Exception {
//setup credentials for docker registry
CredentialsStore store = CredentialsProvider.lookupStores(j.jenkins).iterator().next();

username = System.getProperty("docker.username");
password = System.getProperty("docker.password");

if(password != null) {
if (username != null && password != null) {
UsernamePasswordCredentialsImpl globalCred =
new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL,
"dockerhub", "real", "jtaboada", password);
"dockerhub", "real", username, password);

store.addCredentials(Domain.global(), globalCred);

Expand All @@ -87,9 +89,8 @@ public void agentDocker() throws Exception {

@Test
public void agentDockerWithCreds() throws Exception {
//If there is no password, the test is ignored
if(password != null)
agentDocker("org/jenkinsci/plugins/docker/workflow/declarative/agentDockerWithCreds", "-v /tmp:/tmp");
assumeTrue(username != null && password != null);
agentDocker("org/jenkinsci/plugins/docker/workflow/declarative/agentDockerWithCreds", "-v /tmp:/tmp");
}

@Test
Expand Down
Loading