Rulesets
Branch, tag and push policies (co ruleset)
co ruleset works with rulesets on branches, tags and pushes. A ruleset consists of which refs it applies to (patterns), what it blocks (rules), which repositories it applies to (targets) and who can skip it (bypass). The kinds of rules and how they behave are in the Rulesets feature docs.
All options are in co ruleset <command> --help.
View
co ruleset list # workspace rulesets
co ruleset list --repo collabops-cli # those that apply to this repository
co ruleset view 12 # including rules, targets and bypassCreate and enforce
co ruleset create -n "protect main" --target branch --include main
co ruleset enforce 12 evaluate # only record, without blocking, to check results first
co ruleset rule add 12 --kind block_force_push --scope push # add a rule
co ruleset target add 12 --repo collabops-cli # a repository to apply to
co ruleset enforce 12 active # actually blockA new ruleset is created as active and starts blocking as soon as rules and targets are added. Switch it to evaluate right after creating it, add rules and targets, check the results, then switch it to active. A workspace ruleset with no targets applies to no repository.
Other commands
| Command | What it does |
|---|---|
| edit | Change the name, description and ref patterns |
| bypass | People and roles that can skip the ruleset |
| delete | Delete (asks to confirm; use --yes in scripts) |
Only workspace owners can create, change and delete rulesets. Members can only list and view.
Rule kinds (--kind)
Values for --kind in co ruleset rule add. There are kinds not in this table (allow_rule_bypass, block_direct_push_to_protected_branch, deploy_freeze_window), and if you give a value that does not exist, co shows the full list.
| kind | scope | Description | Parameters |
|---|---|---|---|
| require_change_request | push | Change request required before merge (blocks direct push) | - |
| require_approvals_min_count | merge | At least N approvals | --value N |
| require_approval_from_repo_role | merge | Approval from someone with at least a repository role | --pattern repo:<role>, --value N |
| require_approval_from_workspace_role | merge | Approval from someone with at least a workspace role | --pattern workspace:<role>, --value N |
| require_approval_from_actor | merge | Approval from given users, teams or roles (approvers are set on the web) | --value N |
| require_recent_push_approval | merge | Approval after the last push required | - |
| require_no_pending_rejections | merge | All rejecting reviews must be resolved before merge | - |
| require_ci_pipeline_success | merge | Merge after the CI pipeline succeeds | - |
| require_linked_issue_for_merge | merge | At least one linked issue | - |
| require_branch_up_to_date | merge | Target branch must be up to date | - |
| require_merge_train | merge | Merge only through the merge train | - |
| restrict_merge_to_role | merge | Only the given role or above can merge | --pattern repo:<role> / workspace:<role> |
| allow_merge_commit | merge | Allow merge commits | - |
| allow_squash_merge | merge | Allow squash | - |
| allow_rebase_merge | merge | Allow rebase | - |
| block_force_push | push | Block force push | - |
| block_main_branch_push | push | Block push to the main branch | - |
| require_linear_history | push | Linear history without merge commits | - |
| require_signed_commits | push | Only signed and verified commits | - |
| require_committer_verified | push | Committer is a verified user | - |
| restrict_push_to_role | push | Only the given role or above can push | --pattern repo:<role> / workspace:<role> |
| restrict_creations | push | Restrict ref creation | - |
| restrict_updates | push | Restrict ref updates | - |
| restrict_deletions | push | Restrict ref (branch, tag) deletion | - |
| branch_name_pattern | push | Branch name matches the pattern | --pattern <regex> |
| tag_name_pattern | push | Tag name matches the pattern | --pattern <regex> |
| commit_message_pattern | push | Commit message matches the pattern | --pattern <regex> |
| reject_commit_message_pattern | push | Reject commit messages that match the pattern | --pattern <regex> |
| commit_author_email_pattern | push | Author email matches the pattern | --pattern <regex> |
| committer_email_pattern | push | Committer email matches the pattern | --pattern <regex> |
| max_file_size | push | Block files larger than N MB | --value N |
| restrict_file_paths | push | Reject pushes that touch the given paths | --pattern <path> |