Skip to content

Commit

Permalink
fix issue #149 and issue #151 (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderstumpges authored and pkoenig10 committed Jul 3, 2018
1 parent 94f1979 commit 145c294
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,16 @@ class PalantirDockerPlugin implements Plugin<Project> {
dependsOn prepare
})

Task tag = project.tasks.create('dockerTag', {
group = 'Docker'
description = 'Applies all tags to the Docker image.'
dependsOn exec
})

Exec push = project.tasks.create('dockerPush', Exec, {
group = 'Docker'
description = 'Pushes named Docker image to configured Docker Hub.'
dependsOn exec
dependsOn tag
})

Zip dockerfileZip = project.tasks.create('dockerfileZip', Zip, {
Expand Down Expand Up @@ -114,10 +120,6 @@ class PalantirDockerPlugin implements Plugin<Project> {
}

if (!ext.tags.isEmpty()) {
Task tag = project.tasks.create('dockerTag', {
group = 'Docker'
description = 'Applies all tags to the Docker image.'
})

ext.tags.each { tagName ->
String taskTagName = ucfirst(tagName)
Expand All @@ -135,7 +137,7 @@ class PalantirDockerPlugin implements Plugin<Project> {
description = "Pushes the Docker image with tag '${tagName}' to configured Docker Hub"
workingDir dockerDir
commandLine 'docker', 'push', "${ -> computeName(ext.name, tagName)}"
dependsOn tag
dependsOn subTask
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,30 +227,6 @@ class PalantirDockerPluginTests extends AbstractPluginTest {
buildResult.task(':tasks').outcome == TaskOutcome.SUCCESS
}

def 'no tag task when no tags defined'() {
given:
String id = 'id4'
file('Dockerfile') << """
FROM alpine:3.2
MAINTAINER ${id}
""".stripIndent()
buildFile << """
plugins {
id 'com.palantir.docker'
}
docker {
name '${id}'
}
""".stripIndent()

when:
BuildResult buildResult = with('tasks').build()

then:
!buildResult.output.contains('dockerTag')
}

def 'tag and push tasks created for each tag'() {
given:
String id = 'id5'
Expand Down Expand Up @@ -314,6 +290,7 @@ class PalantirDockerPluginTests extends AbstractPluginTest {
execCond("docker rmi -f ${id}")
execCond("docker rmi -f ${id}:another")
execCond("docker rmi -f ${id}:latest")

}

def 'running tag task creates images with specified tags'() {
Expand Down

0 comments on commit 145c294

Please sign in to comment.