Skip to content

Commit

Permalink
[FIXED JENKINS-42286] Allow dir separator in Dockerfile name
Browse files Browse the repository at this point in the history
  • Loading branch information
abayer committed Feb 23, 2017
1 parent c40dd71 commit d65281d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
Expand Up @@ -588,13 +588,6 @@ class ModelValidatorImpl implements ModelValidator {
}
}
map.variables.each { k, v ->
// TODO: JENKINS-41746 - get rid of this hardcoding and use extensible validation instead once we can
if (typeName == "dockerfile") {
if (k.key == "filename" && (v.toGroovy().contains("/") || v.toGroovy().contains("\\"))) {
errorCollector.error(k, Messages.ModelValidatorImpl_DirSeparatorInDockerfileName())
valid = false
}
}
// Make sure we don't actually include "context" in the valid param names, since, well, it's
// not really one.
List<String> validParamNames = model.parameters.collect { it.name }
Expand Down
Expand Up @@ -218,6 +218,26 @@ public void fromDockerfileInOtherDir() throws Exception {
.go();
}

@Issue("JENKINS-42286")
@Test
public void dirSepInDockerfileName() throws Exception {
assumeDocker();
// Bind mounting /var on OS X doesn't work at the moment
onAllowedOS(PossibleOS.LINUX);

sampleRepo.write("subdir/Dockerfile", "FROM ubuntu:14.04\n\nRUN echo 'HI THERE' > /hi-there\n\n");
sampleRepo.git("init");
sampleRepo.git("add", "subdir/Dockerfile");
sampleRepo.git("commit", "--message=Dockerfile");

expect("fromDockerfileInOtherDir")
.logContains("[Pipeline] { (foo)",
"The answer is 42",
"-v /tmp:/tmp -p 8000:8000",
"HI THERE")
.go();
}

@Test
public void fromDockerfileNoArgs() throws Exception {
assumeDocker();
Expand Down
Expand Up @@ -484,14 +484,6 @@ public void notificationsSectionRemoved() throws Exception {
.go();
}

@Issue("JENKINS-41668")
@Test
public void dirSepInDockerfileName() throws Exception {
expectError("dirSepInDockerfileName")
.logContains(Messages.ModelValidatorImpl_DirSeparatorInDockerfileName())
.go();
}

@Issue("JENKINS-41645")
@Test
public void invalidEnvironmentIdentifiers() throws Exception {
Expand Down
Expand Up @@ -25,7 +25,7 @@
pipeline {
agent {
dockerfile {
filename "Dockerfile/alternate"
filename "subdir/Dockerfile"
args "-v /tmp:/tmp -p 8000:8000"
}
}
Expand Down

0 comments on commit d65281d

Please sign in to comment.