@@ -252,6 +252,7 @@ func runBuild(dockerCli command.Cli, options buildOptions) (err error) {
252252 ),
253253 progress .WithOnClose (func () {
254254 printWarnings (os .Stderr , printer .Warnings (), progressMode )
255+ printBuildDetails (os .Stderr , printer .BuildDetails (), progressMode )
255256 }),
256257 )
257258 if err != nil {
@@ -843,3 +844,45 @@ func printValue(printer printFunc, version string, format string, res map[string
843844 }
844845 return printer ([]byte (res ["result.json" ]), os .Stdout )
845846}
847+
848+ func printBuildDetails (w io.Writer , bds map [string ]progress.BuildDetail , mode string ) {
849+ if len (bds ) == 0 || mode == progress .PrinterModeQuiet {
850+ return
851+ }
852+
853+ bdURL := func (bd progress.BuildDetail ) string {
854+ return fmt .Sprintf ("docker-desktop://dashboard/build/%s/%s/%s" , bd .Builder , bd .Node , bd .Ref )
855+ }
856+
857+ bdWithErr := func (bds map [string ]progress.BuildDetail ) * progress.BuildDetail {
858+ var canceled map [string ]struct {}
859+ for t , bd := range bds {
860+ if bd .Err != nil {
861+ if strings .HasSuffix (bd .Err .Error (), "context canceled" ) {
862+ if canceled == nil {
863+ canceled = make (map [string ]struct {})
864+ }
865+ canceled [t ] = struct {}{}
866+ continue
867+ }
868+ return & bd
869+ }
870+ }
871+ return nil
872+ }(bds )
873+
874+ var out bytes.Buffer
875+ out .WriteString ("View build details: " )
876+ if bdWithErr != nil {
877+ out .WriteString (bdURL (* bdWithErr ))
878+ } else {
879+ multiTargets := len (bds ) > 1
880+ for target , bd := range bds {
881+ if multiTargets {
882+ out .WriteString (fmt .Sprintf ("\n %s: " , target ))
883+ }
884+ out .WriteString (bdURL (bd ))
885+ }
886+ }
887+ fmt .Fprintf (w , "\n %s\n " , out .String ())
888+ }
0 commit comments