Skip to content

Commit

Permalink
Closes #42 Return container id on DockerRun
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaMarkic committed Jul 25, 2018
1 parent 28f0730 commit 45d6751
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Cake.Docker/Container/Run/Docker.Aliases.Run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Cake.Core.Annotations;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Cake.Docker
{
Expand All @@ -17,9 +18,9 @@ partial class DockerAliases
/// <param name="args">The arguments.</param>
/// <param name="command">The command.</param>
[CakeMethodAlias]
public static void DockerRun(this ICakeContext context, string image, string command, params string[] args)
public static string DockerRun(this ICakeContext context, string image, string command, params string[] args)
{
DockerRun(context, new DockerContainerRunSettings(), image, command, args);
return DockerRun(context, new DockerContainerRunSettings(), image, command, args);
}

/// <summary>
Expand All @@ -31,7 +32,7 @@ public static void DockerRun(this ICakeContext context, string image, string com
/// <param name="args">The arguments.</param>
/// <param name="command">The command.</param>
[CakeMethodAlias]
public static void DockerRun(this ICakeContext context, DockerContainerRunSettings settings, string image, string command, params string[] args)
public static string DockerRun(this ICakeContext context, DockerContainerRunSettings settings, string image, string command, params string[] args)
{
if (context == null)
{
Expand All @@ -51,7 +52,7 @@ public static void DockerRun(this ICakeContext context, DockerContainerRunSettin
arguments.AddRange(args);
}
}
runner.Run("run", settings ?? new DockerContainerRunSettings(), arguments.ToArray());
return runner.RunWithResult("run", settings ?? new DockerContainerRunSettings(), r => r.ToArray(), arguments.ToArray()).FirstOrDefault();
}

}
Expand Down

0 comments on commit 45d6751

Please sign in to comment.