Skip to content

Commit b85d92e

Browse files
committed
Add option to mount host ssh agent (--ssh)
1 parent 6ec5e71 commit b85d92e

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

cmd/drone-docker/main.go

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ func main() {
248248
Usage: "additional host:IP mapping",
249249
EnvVar: "PLUGIN_ADD_HOST",
250250
},
251+
cli.StringSliceFlag{
252+
Name: "ssh-agent",
253+
Usage: "mount ssh agent",
254+
EnvVar: "PLUGIN_SSH_AGENT",
255+
},
251256
}
252257

253258
if err := app.Run(os.Args); err != nil {
@@ -267,26 +272,27 @@ func run(c *cli.Context) error {
267272
Config: c.String("docker.config"),
268273
},
269274
Build: docker.Build{
270-
Remote: c.String("remote.url"),
271-
Name: c.String("commit.sha"),
272-
Dockerfile: c.String("dockerfile"),
273-
Context: c.String("context"),
274-
Tags: c.StringSlice("tags"),
275-
Args: c.StringSlice("args"),
276-
ArgsEnv: c.StringSlice("args-from-env"),
277-
Target: c.String("target"),
278-
Squash: c.Bool("squash"),
279-
Pull: c.BoolT("pull-image"),
280-
CacheFrom: c.StringSlice("cache-from"),
281-
Compress: c.Bool("compress"),
282-
Repo: c.String("repo"),
283-
Labels: c.StringSlice("custom-labels"),
284-
LabelSchema: c.StringSlice("label-schema"),
285-
AutoLabel: c.BoolT("auto-label"),
286-
Link: c.String("link"),
287-
NoCache: c.Bool("no-cache"),
288-
AddHost: c.StringSlice("add-host"),
289-
Quiet: c.Bool("quiet"),
275+
Remote: c.String("remote.url"),
276+
Name: c.String("commit.sha"),
277+
Dockerfile: c.String("dockerfile"),
278+
Context: c.String("context"),
279+
Tags: c.StringSlice("tags"),
280+
Args: c.StringSlice("args"),
281+
ArgsEnv: c.StringSlice("args-from-env"),
282+
Target: c.String("target"),
283+
Squash: c.Bool("squash"),
284+
Pull: c.BoolT("pull-image"),
285+
CacheFrom: c.StringSlice("cache-from"),
286+
Compress: c.Bool("compress"),
287+
Repo: c.String("repo"),
288+
Labels: c.StringSlice("custom-labels"),
289+
LabelSchema: c.StringSlice("label-schema"),
290+
AutoLabel: c.BoolT("auto-label"),
291+
Link: c.String("link"),
292+
NoCache: c.Bool("no-cache"),
293+
AddHost: c.StringSlice("add-host"),
294+
Quiet: c.Bool("quiet"),
295+
SSHAgent: c.String("ssh-agent"),
290296
},
291297
Daemon: docker.Daemon{
292298
Registry: c.String("docker.registry"),

docker.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ type (
5959
NoCache bool // Docker build no-cache
6060
AddHost []string // Docker build add-host
6161
Quiet bool // Docker build quiet
62+
SSHAgent string // Docker build ssh
6263
}
6364

6465
// Plugin defines the Docker plugin parameters.
@@ -264,6 +265,9 @@ func commandBuild(build Build) *exec.Cmd {
264265
if build.Quiet {
265266
args = append(args, "--quiet")
266267
}
268+
if build.SSHAgent != "" {
269+
args = append(args, "--ssh", build.SSHAgent)
270+
}
267271

268272
if build.AutoLabel {
269273
labelSchema := []string{

0 commit comments

Comments
 (0)