Docker Command Step
A build step for a generic docker command runner (can run Docker build, push, other...)
Example. Adds a Docker Build build step with a source as Dockerfile located in the checkout directory with extra Docker command line argument.
buildType {
// Other Build Type settings ...
steps {
// Other Build Steps ...
dockerCommand {
name = "My Docker step"
commandType = build {
source = file {
path = "my-docker/Dockerfile"
}
commandArgs = "--pull"
}
}
Content copied to clipboard }
}
Example. Adds a Docker Build build step with a URL as Dockerfile with extra platform settings and images names and tags provided (using parameter reference).
buildType {
// Other Build Type settings ...
steps {
// Other Build Steps ...
dockerCommand {
name = "My Docker step"
commandType = build {
source = url {
url = "https://my.repo.org/files/Dockerfile"
}
platform = DockerCommandStep.ImagePlatform.Linux
namesAndTags = """
imageName:%myimage.version%
otherImage:%myimage.version%
""".trimIndent()
}
}
Content copied to clipboard }
}
Example. Adds a Docker Build build step with a source as Dockerfile content provided explicitly in the DSL configuration with extra platform settings and images names and tags provided.
buildType {
// Other Build Type settings ...
steps {
// Other Build Steps ...
dockerCommand {
name = "My Docker step"
commandType = build {
source = content {
content = """
Dockerfile content
""".trimIndent()
}
platform = DockerCommandStep.ImagePlatform.Linux
namesAndTags = "myImage:1.0"
}
}
Content copied to clipboard }
}
Example. Adds a Docker Push build step with images names and tags provided (using parameter reference). Additional property for not removing the image after the step is set up. This step will we executed only if build status is sucessfull for previous build steps and extra condition is met.
buildType {
// Other Build Type settings ...
steps {
// Other Build Steps ...
dockerCommand {
name = "My Docker push step"
executionMode = BuildStep.ExecutionMode.RUN_ON_SUCCESS
conditions {
equals("teamcity.build.branch", "release")
}
commandType = push {
namesAndTags = "imageName:%myimage.version%"
removeImageAfterPush = false
}
}
Content copied to clipboard }
}
Example. Adds a Docker Other build step with a docker command provided and Docker command additional arguments. Custom working directory is provided.
buildType {
// Other Build Type settings ...
steps {
// Other Build Steps ...
dockerCommand {
name = "My Docker other (tag) step"
commandType = other {
subCommand = "tag"
workingDir = "docker/images"
commandArgs = "source target:%myimage.version%"
}
}
Content copied to clipboard }
}
See also
Properties
Specifies the type of the command, at the moment "build", "push", "other"
Optional collection of build step execution conditions
Build step execution mode
Functions
Run "docker build" command
Deletes all configured build step conditions
Configures build step conditions
Copies parameters of this object to the specified target
Run a specified docker command
Run "docker push" command
Validates this object and reports found errors to the provided consumer