Explicitly call toString() on values in maps
MODIFY
src/functTest/groovy/com/bmuschko/gradle/docker/DockerCreateContainerFunctionalTest.groovy
src/functTest/groovy/com/bmuschko/gradle/docker/DockerCreateContainerFunctionalTest.groovy
@@ -37,6 +37,7 @@ class DockerCreateContainerFunctionalTest extends AbstractFunctionalTest {
cmd = ['ifconfig']
macAddress = '02:03:04:05:06:07'
cpuset = '1'
+ labels = ["project.name": "\$project.name"]
}
task startContainer(type: DockerStartContainer) {

MODIFY
src/functTest/groovy/com/bmuschko/gradle/docker/tasks/image/DockerBuildImageFunctionalTest.groovy
src/functTest/groovy/com/bmuschko/gradle/docker/tasks/image/DockerBuildImageFunctionalTest.groovy
@@ -126,7 +126,7 @@ class DockerBuildImageFunctionalTest extends AbstractFunctionalTest {
task buildImage(type: DockerBuildImage) {
dependsOn dockerfile
inputDir = file("build/docker")
- buildArgs = ['arg1':'test1', 'arg2':'test2']
+ buildArgs = ['arg1':'test1', 'arg2':'test2', 'arg3': "\$project.name"]
}
task inspectImage(type: DockerInspectImage) {
@@ -149,7 +149,7 @@ class DockerBuildImageFunctionalTest extends AbstractFunctionalTest {
task buildImage(type: DockerBuildImage) {
dependsOn dockerfile
inputDir = file("build/docker")
- labels = ['label1':'test1', 'label2':'test2']
+ labels = ['label1':'test1', 'label2':'test2', 'label3':"\$project.name"]
}
task inspectImage(type: DockerInspectImage) {
@@ -164,6 +164,8 @@ class DockerBuildImageFunctionalTest extends AbstractFunctionalTest {
import com.bmuschko.gradle.docker.tasks.image.Dockerfile
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
+ project.version = "123"
+
task dockerfile(type: Dockerfile) {
from '$TEST_IMAGE_WITH_TAG'
}
@@ -171,7 +173,7 @@ class DockerBuildImageFunctionalTest extends AbstractFunctionalTest {
task buildImageWithTags(type: DockerBuildImage) {
dependsOn dockerfile
inputDir = file("build/docker")
- tags = ['test/image:123', 'registry.com:5000/test/image:123']
+ tags = ['test/image:123', "registry.com:5000/test/image:\$project.version"]
}
task buildImageWithTag(type: DockerBuildImage) {

MODIFY
src/functTest/groovy/com/bmuschko/gradle/docker/tasks/image/DockerListImagesFunctionalTest.groovy
src/functTest/groovy/com/bmuschko/gradle/docker/tasks/image/DockerListImagesFunctionalTest.groovy
@@ -55,9 +55,11 @@ class DockerListImagesFunctionalTest extends AbstractFunctionalTest {
buildFile << """
import com.bmuschko.gradle.docker.tasks.image.DockerListImages
+ String imageId = "${ImageId}"
+
task listImages(type: DockerListImages) {
showAll = true
- labels = ["setup":"${ImageId}"]
+ labels = ["setup":"\$imageId"]
onNext { images ->
if(!images.every { image -> image.repoTags.contains("${ImageId}:latest") }) {

MODIFY
src/main/groovy/com/bmuschko/gradle/docker/tasks/container/DockerCreateContainer.groovy
src/main/groovy/com/bmuschko/gradle/docker/tasks/container/DockerCreateContainer.groovy
@@ -374,7 +374,7 @@ class DockerCreateContainer extends AbstractDockerRemoteApiTask {
}
if(getLabels()) {
- containerCommand.withLabels(getLabels())
+ containerCommand.withLabels(getLabels().collectEntries { [it.key, it.value.toString()] })
}
if(getMacAddress()) {

MODIFY
src/main/groovy/com/bmuschko/gradle/docker/tasks/image/DockerBuildImage.groovy
src/main/groovy/com/bmuschko/gradle/docker/tasks/image/DockerBuildImage.groovy
@@ -119,7 +119,7 @@ class DockerBuildImage extends AbstractDockerRemoteApiTask implements RegistryCr
} else if (getTags()) {
def tagListString = getTags().collect {"'${it}'"}.join(", ")
logger.quiet "Using tags ${tagListString} for image."
- buildImageCmd.withTags(getTags())
+ buildImageCmd.withTags(getTags().collect { it.toString() }.toSet() )
}
if (getNoCache()) {
@@ -139,7 +139,7 @@ class DockerBuildImage extends AbstractDockerRemoteApiTask implements RegistryCr
}
if (getLabels()) {
- buildImageCmd.withLabels(getLabels())
+ buildImageCmd.withLabels(getLabels().collectEntries { [it.key, it.value.toString()] })
}
if(getShmSize() != null) { // 0 is valid input

MODIFY
src/main/groovy/com/bmuschko/gradle/docker/tasks/image/DockerListImages.groovy
src/main/groovy/com/bmuschko/gradle/docker/tasks/image/DockerListImages.groovy
@@ -53,7 +53,7 @@ class DockerListImages extends AbstractDockerRemoteApiTask {
}
if (getLabels()) {
- listImagesCmd.withLabelFilter(getLabels())
+ listImagesCmd.withLabelFilter(getLabels().collectEntries { [it.key, it.value.toString()] })
}
if (getImageName()) {

Explicitly call toString() on values in maps (#595)