Group push rules API
- Tier: Premium, Ultimate
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
The following push rules endpoints are only available to group owners and administrators.
Get the push rules of a group
Gets the push rules of a group.
GET /groups/:id/push_rule
Supported attributes:
Attribute | Type | Required | Description |
---|---|---|---|
id | integer/string | yes | The ID of the group or URL-encoded path of the group. |
Example request:
curl \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/groups/2/push_rule"
Example response:
{
"id": 1,
"created_at": "2020-08-17T19:09:19.580Z",
"commit_committer_check": true,
"commit_committer_name_check": true,
"reject_unsigned_commits": false,
"reject_non_dco_commits": false,
"commit_message_regex": "[a-zA-Z]",
"commit_message_negative_regex": "[x+]",
"branch_name_regex": "[a-z]",
"deny_delete_tag": true,
"member_check": true,
"prevent_secrets": true,
"author_email_regex": "^[A-Za-z0-9.]+@gitlab.com$",
"file_name_regex": "(exe)$",
"max_file_size": 100
}
Add push rules to a group
Adds push rules to the group. Use only if you haven’t defined any push rules so far.
POST /groups/:id/push_rule
Supported attributes:
Attribute | Type | Required | Description |
---|---|---|---|
id | integer/string | yes | The ID or URL-encoded path of the group. |
deny_delete_tag | boolean | no | Deny deleting a tag. |
member_check | boolean | no | Allow only GitLab users to author commits. |
prevent_secrets | boolean | no | Reject files that are likely to contain secrets. |
commit_message_regex | string | no | Allow only commit messages that match the regular expression provided in this attribute, for example, Fixed \d+\..* . |
commit_message_negative_regex | string | no | Reject commit messages matching the regular expression provided in this attribute, for example, ssh\:\/\/ . |
branch_name_regex | string | no | Allow only branch names that match the regular expression provided in this attribute, for example, `(feature |
author_email_regex | string | no | Allow only commit author emails that match the regular expression provided in this attribute, for example, @my-company.com$ . |
file_name_regex | string | no | Reject filenames matching the regular expression provided in this attribute, for example, `(jar |
max_file_size | integer | no | Maximum file size (MB) allowed. |
commit_committer_check | boolean | no | Allow commits from users only if the committer email is one of their own verified emails. |
commit_committer_name_check | boolean | no | Allow commits from users only if the commit author name is consistent with their GitLab account name. |
reject_unsigned_commits | boolean | no | Reject a commit when it’s not signed. |
reject_non_dco_commits | boolean | no | Reject a commit when it’s not DCO certified. |
Example request:
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/groups/19/push_rule?prevent_secrets=true"
Example response:
{
"id": 1,
"created_at": "2020-08-31T15:53:00.073Z",
"commit_committer_check": false,
"commit_committer_name_check": false,
"reject_unsigned_commits": false,
"reject_non_dco_commits": false,
"commit_message_regex": "[a-zA-Z]",
"commit_message_negative_regex": "[x+]",
"branch_name_regex": null,
"deny_delete_tag": false,
"member_check": false,
"prevent_secrets": true,
"author_email_regex": "^[A-Za-z0-9.]+@gitlab.com$",
"file_name_regex": null,
"max_file_size": 100
}
Edit the push rules of a group
Edits the push rules for the group.
PUT /groups/:id/push_rule
Attribute | Type | Required | Description |
---|---|---|---|
id | integer/string | yes | The ID or URL-encoded path of the group. |
deny_delete_tag | boolean | no | Deny deleting a tag. |
member_check | boolean | no | Allow only GitLab users to author commits. |
prevent_secrets | boolean | no | Reject files that are likely to contain secrets. |
commit_message_regex | string | no | Allow only commit messages that match the regular expression provided in this attribute, for example, Fixed \d+\..* . |
commit_message_negative_regex | string | no | Reject commit messages matching the regular expression provided in this attribute, for example, ssh\:\/\/ . |
branch_name_regex | string | no | Allow only branch names that match the regular expression provided in this attribute, for example, `(feature |
author_email_regex | string | no | Allow only commit author emails that match the regular expression provided in this attribute, for example, @my-company.com$ . |
file_name_regex | string | no | Reject filenames matching the regular expression provided in this attribute, for example, `(jar |
max_file_size | integer | no | Maximum file size (MB) allowed. |
commit_committer_check | boolean | no | Allow commits from users only if the committer email is one of their own verified emails. |
commit_committer_name_check | boolean | no | Allow commits from users only if the commit author name is consistent with their GitLab account name. |
reject_unsigned_commits | boolean | no | Reject a commit when it’s not signed. |
reject_non_dco_commits | boolean | no | Reject a commit when it’s not DCO certified. |
Example request:
curl --request PUT \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/groups/19/push_rule?member_check=true"
Example response:
{
"id": 19,
"created_at": "2020-08-31T15:53:00.073Z",
"commit_committer_check": false,
"commit_committer_name_check": false,
"reject_unsigned_commits": false,
"reject_non_dco_commits": false,
"commit_message_regex": "[a-zA-Z]",
"commit_message_negative_regex": "[x+]",
"branch_name_regex": null,
"deny_delete_tag": false,
"member_check": true,
"prevent_secrets": false,
"author_email_regex": "^[A-Za-z0-9.]+@staging.gitlab.com$",
"file_name_regex": null,
"max_file_size": 100
}
Delete the push rules of a group
Deletes all the push rules of a group.
DELETE /groups/:id/push_rule
Supported attributes:
Attribute | Type | Required | Description |
---|---|---|---|
id | integer/string | yes | The ID or URL-encoded path of the group. |
Example request:
curl --request DELETE \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/groups/19/push_rule"
If successful, no response is returned.
Docs
Edit this page to fix an error or add an improvement in a merge request.
Create an issue to suggest an improvement to this page.
Product
Create an issue if there's something you don't like about this feature.
Propose functionality by submitting a feature request.
Feature availability and product trials
View pricing to see all GitLab tiers and features, or to upgrade.
Try GitLab for free with access to all features for 30 days.
Get help
If you didn't find what you were looking for, search the docs.
If you want help with something specific and could use community support, post on the GitLab forum.
For problems setting up or using this feature (depending on your GitLab subscription).
Request support