Skip to content

Add push rules to a project

POST
/api/v4/projects/{id}/push_rule

Adds push rules to a specified project.

id
required
One of:
string

The ID or URL-encoded path of the project

Media type application/json
object
deny_delete_tag

Deny deleting a tag

boolean
nullable
Example
true
member_check

Restrict commits by author (email) to existing GitLab users

boolean
nullable
Example
true
prevent_secrets

GitLab will reject any files that are likely to contain secrets

boolean
nullable
Example
true
commit_message_regex

All commit messages must match this

string
nullable
Example
Fixed \d+\..*
commit_message_negative_regex

No commit message is allowed to match this

string
nullable
Example
ssh\:\/\/
branch_name_regex

All branches names must match this

string
nullable
Example
(feature|hotfix)\/.*
author_email_regex

All commit author emails must match this

string
nullable
Example
@my-company.com$
file_name_regex

All committed filenames must not match this

string
nullable
Example
(jar|exe)$
max_file_size

Maximum file size (MB)

integer
nullable
Example
1024
commit_committer_check

Users can only push commits to this repository if the committer email is one of their own verified emails.

boolean
nullable
Example
true
commit_committer_name_check

Users can only push commits to this repository if the commit author name is consistent with their GitLab account name.

boolean
nullable
Example
true
reject_unsigned_commits

Reject commit when it’s not signed.

boolean
nullable
Example
true
reject_non_dco_commits

Reject commit when it’s not DCO certified.

boolean
nullable
Example
true

Created

Media type application/json
object
id
integer format: int64
project_id
integer format: int64
created_at
string format: date-time
commit_message_regex
string
commit_message_negative_regex
string
branch_name_regex
string
deny_delete_tag
boolean
member_check
boolean
prevent_secrets
boolean
author_email_regex
string
file_name_regex
string
max_file_size
integer
commit_committer_check
boolean
commit_committer_name_check
boolean
reject_unsigned_commits
boolean
reject_non_dco_commits
boolean
Example
{
"id": 2,
"project_id": 3,
"created_at": "2020-08-31T15:53:00.073Z",
"commit_message_regex": "Fixed \\d+\\..*",
"commit_message_negative_regex": "ssh\\:\\/\\/",
"branch_name_regex": "(feature|hotfix)\\/.*",
"deny_delete_tag": true,
"member_check": true,
"prevent_secrets": true,
"author_email_regex": "@my-company.com$",
"file_name_regex": "(jar|exe)$",
"max_file_size": 1024,
"commit_committer_check": true,
"commit_committer_name_check": true,
"reject_unsigned_commits": true,
"reject_non_dco_commits": true
}

Validation error

Not found

Unprocessable entity