Docs
CLICode

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 bypass

Create 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 block

A 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

CommandWhat it does
editChange the name, description and ref patterns
bypassPeople and roles that can skip the ruleset
deleteDelete (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.

kindscopeDescriptionParameters
require_change_requestpushChange request required before merge (blocks direct push)-
require_approvals_min_countmergeAt least N approvals--value N
require_approval_from_repo_rolemergeApproval from someone with at least a repository role--pattern repo:<role>, --value N
require_approval_from_workspace_rolemergeApproval from someone with at least a workspace role--pattern workspace:<role>, --value N
require_approval_from_actormergeApproval from given users, teams or roles (approvers are set on the web)--value N
require_recent_push_approvalmergeApproval after the last push required-
require_no_pending_rejectionsmergeAll rejecting reviews must be resolved before merge-
require_ci_pipeline_successmergeMerge after the CI pipeline succeeds-
require_linked_issue_for_mergemergeAt least one linked issue-
require_branch_up_to_datemergeTarget branch must be up to date-
require_merge_trainmergeMerge only through the merge train-
restrict_merge_to_rolemergeOnly the given role or above can merge--pattern repo:<role> / workspace:<role>
allow_merge_commitmergeAllow merge commits-
allow_squash_mergemergeAllow squash-
allow_rebase_mergemergeAllow rebase-
block_force_pushpushBlock force push-
block_main_branch_pushpushBlock push to the main branch-
require_linear_historypushLinear history without merge commits-
require_signed_commitspushOnly signed and verified commits-
require_committer_verifiedpushCommitter is a verified user-
restrict_push_to_rolepushOnly the given role or above can push--pattern repo:<role> / workspace:<role>
restrict_creationspushRestrict ref creation-
restrict_updatespushRestrict ref updates-
restrict_deletionspushRestrict ref (branch, tag) deletion-
branch_name_patternpushBranch name matches the pattern--pattern <regex>
tag_name_patternpushTag name matches the pattern--pattern <regex>
commit_message_patternpushCommit message matches the pattern--pattern <regex>
reject_commit_message_patternpushReject commit messages that match the pattern--pattern <regex>
commit_author_email_patternpushAuthor email matches the pattern--pattern <regex>
committer_email_patternpushCommitter email matches the pattern--pattern <regex>
max_file_sizepushBlock files larger than N MB--value N
restrict_file_pathspushReject pushes that touch the given paths--pattern <path>

Table of Contents

AI tools

Was this helpful?