@@ -15,6 +15,7 @@ import (
15
15
"github.com/drone/drone/queue"
16
16
17
17
"github.com/codegangsta/cli"
18
+ "github.com/joho/godotenv"
18
19
)
19
20
20
21
var execCmd = cli.Command {
@@ -41,6 +42,11 @@ var execCmd = cli.Command{
41
42
Usage : "build secrets in KEY=VALUE format" ,
42
43
EnvVar : "DRONE_SECRET" ,
43
44
},
45
+ cli.StringFlag {
46
+ Name : "secrets-file" ,
47
+ Usage : "build secrets file in KEY=VALUE format" ,
48
+ EnvVar : "DRONE_SECRETS_FILE" ,
49
+ },
44
50
cli.StringSliceFlag {
45
51
Name : "matrix" ,
46
52
Usage : "build matrix in KEY=VALUE format" ,
@@ -401,7 +407,27 @@ func getMatrix(c *cli.Context) map[string]string {
401
407
402
408
// helper function to retrieve secret variables.
403
409
func getSecrets (c * cli.Context ) []* model.Secret {
410
+
404
411
var secrets []* model.Secret
412
+
413
+ if c .String ("secrets-file" ) != "" {
414
+ envs , _ := godotenv .Read (c .String ("secrets-file" ))
415
+ for k , v := range envs {
416
+ secret := & model.Secret {
417
+ Name : k ,
418
+ Value : v ,
419
+ Events : []string {
420
+ model .EventPull ,
421
+ model .EventPush ,
422
+ model .EventTag ,
423
+ model .EventDeploy ,
424
+ },
425
+ Images : []string {"*" },
426
+ }
427
+ secrets = append (secrets , secret )
428
+ }
429
+ }
430
+
405
431
for _ , s := range c .StringSlice ("secret" ) {
406
432
parts := strings .SplitN (s , "=" , 2 )
407
433
if len (parts ) != 2 {
0 commit comments