-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api,ui): add workflow retention policy (#5474)
- Loading branch information
Showing
47 changed files
with
1,145 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/ovh/cds/cli" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var adminWorkflowsCmd = cli.Command{ | ||
Name: "workflows", | ||
Aliases: []string{"workflow"}, | ||
Short: "Manage CDS workflows", | ||
} | ||
|
||
func adminWorkflows() *cobra.Command { | ||
return cli.NewCommand(adminWorkflowsCmd, nil, []*cobra.Command{ | ||
cli.NewCommand(adminWorkflowUpdateMaxRunCmd, adminWorkflowUpdateMaxRun, nil), | ||
}) | ||
} | ||
|
||
var adminWorkflowUpdateMaxRunCmd = cli.Command{ | ||
Name: "maxrun", | ||
Short: "Update the maximum number of workflow executions", | ||
Args: []cli.Arg{ | ||
{ | ||
Name: "projectKey", | ||
}, | ||
{ | ||
Name: "workflowName", | ||
}, | ||
{ | ||
Name: "maxRuns", | ||
}, | ||
}, | ||
} | ||
|
||
func adminWorkflowUpdateMaxRun(v cli.Values) error { | ||
maxRuns, err := v.GetInt64("maxRuns") | ||
if err != nil { | ||
return err | ||
} | ||
return client.AdminWorkflowUpdateMaxRuns(v.GetString("projectKey"), v.GetString("workflowName"), maxRuns) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ notifications: | |
on_success: never | ||
recipients: | ||
- [email protected] | ||
retention_policy: return run_days_before < 7 | ||
``` | ||
There are two major things to understand: `workflow` and `hooks`. A workflow is a kind of graph starting from a root pipeline, and other pipelines with dependencies. In this example, the `deploy` pipeline will be triggered after the `build` pipeline. | ||
|
@@ -143,3 +144,7 @@ workflow: | |
# ... | ||
one_at_a_time: true # No concurent deployments | ||
``` | ||
|
||
## Retention Policy | ||
|
||
[Retention documentation]({{<relref "/docs/concepts/workflow/retention.md">}}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: "Retention" | ||
weight: 10 | ||
--- | ||
|
||
You can configure the workflow run retention in the workflow advanced section on the CDS UI. | ||
|
||
![retention.png](../images/workflow_retention.png) | ||
|
||
|
||
* The first line defines the number maximum of runs that CDS can keep for this workflow. Only a CDS administrator can update this value. | ||
|
||
* On the second line, you will be able to define your retention policy through a lua condition. | ||
You will be able to use these variables: | ||
* run_days_before: to identify runs older than x days | ||
* git_branch_exist: to identify if the git branch used for this run still exists on the git repository | ||
* run_status: to identidy run status | ||
* and all variables defined in your workflow payload | ||
|
||
For example, the rule defined above means: | ||
|
||
Keep workflow run for 365 days, but if branch does not exist on repository, only keep the run for 2 days. | ||
|
||
|
||
* The dry run button allows you to test your lua expression. The result is a table filled with all runs that would be kept |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.