mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-10-21 14:21:52 +00:00
Add server configuration option to add default set of labels for workflows that has no labels specified (#4326)
This commit is contained in:
@@ -173,6 +173,11 @@ var flags = append([]cli.Flag{
|
||||
Usage: "The maximum time in minutes you can set in the repo settings before a pipeline gets killed",
|
||||
Value: 120,
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Sources: cli.EnvVars("WOODPECKER_DEFAULT_WORKFLOW_LABELS"),
|
||||
Name: "default-workflow-labels",
|
||||
Usage: "The default label filter to set for workflows that has no label filter set. By default workflows will be allowed to run on any agent, if not specified in the workflow.",
|
||||
},
|
||||
&cli.DurationFlag{
|
||||
Sources: cli.EnvVars("WOODPECKER_SESSION_EXPIRES"),
|
||||
Name: "session-expires",
|
||||
|
@@ -188,6 +188,17 @@ func setupEvilGlobals(ctx context.Context, c *cli.Command, s store.Store) (err e
|
||||
server.Config.Pipeline.DefaultTimeout = c.Int("default-pipeline-timeout")
|
||||
server.Config.Pipeline.MaxTimeout = c.Int("max-pipeline-timeout")
|
||||
|
||||
_labels := c.StringSlice("default-workflow-labels")
|
||||
labels := make(map[string]string, len(_labels))
|
||||
for _, v := range _labels {
|
||||
name, value, ok := strings.Cut(v, "=")
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid label filter: %s", v)
|
||||
}
|
||||
labels[name] = value
|
||||
}
|
||||
server.Config.Pipeline.DefaultWorkflowLabels = labels
|
||||
|
||||
// backend options for pipeline compiler
|
||||
server.Config.Pipeline.Proxy.No = c.String("backend-no-proxy")
|
||||
server.Config.Pipeline.Proxy.HTTP = c.String("backend-http-proxy")
|
||||
|
Reference in New Issue
Block a user