Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cli/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"runtime"
"strings"

"codeberg.org/6543/xyaml"
"github.com/drone/envsubst"
"github.com/oklog/ulid/v2"
"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -169,6 +170,25 @@ func execWithAxis(ctx context.Context, c *cli.Command, file, repoPath string, ax
Value: val,
})
}
if secretsFile := c.String("secrets-file"); secretsFile != "" {
fileContent, err := os.ReadFile(secretsFile)
if err != nil {
return err
}

var m map[string]string
err = xyaml.Unmarshal(fileContent, &m)
if err != nil {
return err
}

for key, val := range m {
secrets = append(secrets, compiler.Secret{
Name: key,
Value: val,
})
}
}

pipelineEnv := make(map[string]string)
for _, env := range c.StringSlice("env") {
Expand Down
5 changes: 5 additions & 0 deletions cli/exec/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ var flags = []cli.Flag{
Name: "secrets",
Usage: "map of secrets, ex. 'secret=\"val\",secret2=\"value2\"'",
},
&cli.StringFlag{
Sources: cli.EnvVars("WOODPECKER_SECRETS_FILE"),
Name: "secrets",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it supposed to be secrets-file ? @qwerty287

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it is. This can't work right now... You want to open a PR to fix it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I can fix it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usage: "path to yaml file with secrets map",
},

//
// backend options for pipeline compiler
Expand Down