will be upgraded to critical security release 13.7.4 Monday, 11/18 between 9 and 10pm. Please email if you have trouble with anything Gitlab-related. Please see the Yammer group for more information.

Commit f3a9b7a9 authored by Andy Cobaugh's avatar Andy Cobaugh

add ci for-each-image subcommand

parent a1a09e14
Pipeline #108710 waiting for manual action with stages
in 1 minute and 31 seconds
package cmd
import (
// ciForEachImageCmd represents the build command
var ciForEachImageCmd = &cobra.Command{
Use: "for-each-image",
Short: "run a command for each deployable image in config",
Long: "The given command is run for each deployable defined in the config file. The DT_DEPLOYABLE and DT_DOCKERFILE env vars are set to the deployable name and dockerfile. A non-zero exit code for any invocation will result in devtool exiting with error code 1. All commands will be run in succession to completion, with exit codes reported at the end.",
Args: cobra.MinimumNArgs(1),
RunE: ciForEachImage,
func init() {
type forEachImageResult struct {
name string
e error
func ciForEachImage(cmd *cobra.Command, args []string) error {
config := getCiConfiguration()
color.Blue("Running for-each-image: %+v", args)
var results []forEachImageResult
var errors []error
for _, d := range config.Deployables {
color.New(color.FgGreen).Printf("=== Deployable: %s\n", d.Name)
if d.LocalOnly {
color.New(color.FgYellow).Printf("Deployable %s is set to LocalOnly, skipping.\n", d.Name)
if d.Dockerfile == "" {
color.New(color.FgYellow).Printf("Deployable %s has no Dockerfile, skipping.\n", d.Name)
os.Setenv("DT_DEPLOYABLE", d.Name)
os.Setenv("DT_DOCKERFILE", d.Dockerfile)
for i := range args {
args[i] = os.ExpandEnv(args[i])
err := environment.Run(true, args[0], args[1:]...)
results = append(results, forEachImageResult{name: d.Name, e: err})
if err != nil {
color.New(color.FgHiRed).Printf("error: %s\n", err)
for _, r := range results {
fmt.Printf("%s: ",
if r.e != nil {
color.New(color.FgRed).Printf("%s\n", r.e)
errors = append(errors, r.e)
} else {
if len(errors) > 0 {
return fmt.Errorf("%+v", errors)
return nil
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment