Creating a Repository Commit Rule
Function
This API is used to create a repository commit rule.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
Authorization Information
Each account root user has all the permissions required to call all APIs, but IAM users must be assigned the following required identity policy-based permissions. For details about the required permissions, see Permissions Policies and Supported Actions.
|
Action |
Access Level |
Resource Type (*: required) |
Condition Key |
Alias |
Dependencies |
|---|---|---|---|---|---|
|
codeartsrepo:repository:setRepository |
Write |
- |
- |
- |
- |
URI
POST https://{hostURL}/v4/repositories/{repository_id}/commit-rules
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
repository_id |
Yes |
Integer |
Definition You can query the project list to obtain the repository ID by calling the API used to query user's all repositories. Constraints N/A Default Value N/A Value range: 1~2147483647 |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
Definition User token. Obtain one by calling the IAM API Obtaining a User Token. The value of X-Subject-Token in the response header is a token. Constraints N/A Range 1–100,000 characters. Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
name |
Yes |
String |
Definition: Rule name Constraints: Mandatory Value range: N/A Default value: N/A |
|
branch_name |
Yes |
String |
Definition: Branch rule Constraints: Mandatory Value range: N/A Default value: N/A |
|
commit_message_regex |
No |
String |
Definition: Commit message match Regular expression that every commit message must match, for example, \d+..* Every commit message that matches the regex can be committed. If this field is left blank, all messages can be committed. For E2E code tracing, you can set this expression to require that the committed information must contain a work item number. Constraints: N/A Value range: N/A Default value: N/A |
|
commit_message_negative_regex |
No |
String |
Definition: Commit message negative match Regular expression that every commit message must match, for example, \d+..* Every file name that matches the regex provided in it, will be rejected. If this field is left blank, all messages can be committed. Constraints: N/A Value range: N/A Default value: N/A |
|
author_regex |
No |
String |
Definition: Regular expression of the committer. Regular expression matching must be performed for the committer, for example, /([a-zA-Z]\d){7}/. If this field is left blank, any committer is allowed. Constraints: N/A Value range: N/A Default value: N/A |
|
author_email_regex |
No |
String |
Definition: Regular expression of the committer's email address. Regular expression matching must be performed for all committer's email addresses, for example, @my-company.com$. If this field is left blank, any committer email address is allowed. Constraints: N/A Value range: N/A Default value: N/A |
|
prohibited_file_name_regex |
No |
String |
Definition: Regular expression of the file name that cannot be committed. Constraints: N/A Value range: N/A Default value: N/A |
|
max_file_size |
No |
Integer |
Definition: Maximum size of a single file, in MB. If the size of a single file exceeds the specified value, the addition or update push will be rejected. Repo recommends max. 50 MB. The system supports max. 300 MB for each file. Constraints: N/A Value range: N/A Default value: 50 Value range: 1~300 |
|
binary_gate_enabled |
No |
Boolean |
Definition: Do not allow new binary files (privileged users excepted) Constraints: N/A Value range:
Default value: N/A |
|
allowed_modify_binary |
No |
Boolean |
Definition: Allow changes to binary files (privileged users excepted) Constraints: N/A Value range:
Default value: N/A |
|
allowed_binary_file_name_regex |
No |
String |
Definition: Binary file whitelist (files that can be directly imported to the database) All pushed binary file names must match the regular expression, for example, (.png|.xls|.xlsx|.docx|.doc)$. Constraints: N/A Value range: N/A Default value: N/A |
|
privileged_user_ids |
No |
Array of integers |
Definition: Privileged user ID list (users who can directly push all binary files to the database) Only privileged users can push binary files. Constraints: N/A Value range: N/A Default value: N/A Value range: 1~2147483647 |
|
effective_date |
No |
String |
Definition: Rule effective time, for example, 2025-8-19. Constraints: N/A Value range: N/A Default value: N/A |
|
skip_rule_check |
No |
Boolean |
Definition: Rule detection is skipped. Constraints: This parameter is available only for the CR repository. Value range: N/A Default value: N/A |
|
skip_rule_end_date |
No |
String |
Definition: Expiration time of rule skipping, for example, 2025-8-19 10:00:00. Constraints: This parameter is available only for the CR repository. Value range: N/A Default value: N/A |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
Integer |
Definition: Primary key ID. Value range: N/A. Value range: 1~2147483647 |
|
repository_id |
Integer |
Definition: Repository ID. Value range: N/A. Value range: 1~2147483647 |
|
commit_message_regex |
String |
Definition: Commit message match. |
|
commit_message_negative_regex |
String |
Definition: Commit message negative match. |
|
prohibited_file_name_regex |
String |
Definition: File name that cannot be submitted. |
|
author_email_regex |
String |
Definition: Committer's email address. |
|
max_file_size |
Integer |
Definition: Maximum size of a single file, in MB. Value range: 0~300 |
|
allowed_max_file_size |
Integer |
Definition: Maximum size of a single file, in MB. Value range: 0~300 |
|
effective_date |
String |
Definition: Rule effective time. |
|
binary_gate_enabled |
Boolean |
Definition: Whether to forbid new binary files (invalid for privileged users). Constraints: N/A. Value range:
|
|
privileged_users |
Array of RepositoryUserBasicDto objects |
Definition: Privileged user (who can directly push all binary files to the database). |
|
allowed_modify_binary |
Boolean |
Definition: Whether to allow changes to binary files (privileged users excepted). Constraints: N/A. Value range:
|
|
allowed_binary_file_name_regex |
String |
Definition: Binary file whitelist (that can be imported to the database). |
|
author_regex |
AnyType |
Definition: Committer. |
|
updated_at |
String |
Definition: Update time. |
|
name |
String |
Definition: Rule name. Constraints: N/A. Value range: N/A. Default value: N/A. |
|
branch_name |
String |
Definition: Branch rule. Constraints: N/A. Value range: N/A. Default value: N/A. |
|
created_at |
String |
Definition: Creation time. Constraints: N/A. Value range: N/A. Default value: N/A. |
|
skip_rule_check |
Boolean |
Definition: Rule detection is skipped. Constraints: This parameter is available only for the CR repository. |
|
skip_rule_end_date |
String |
Definition: Expiration time of rule skipping, for example, 2025-8-19. Constraints: This parameter is available only for the CR repository. |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
Integer |
Definition: User ID. Constraints: N/A. Value range: 1~2147483647 |
|
name |
String |
Definition: Username. Constraints: N/A. |
|
username |
String |
Definition: Username. Constraints: N/A. |
|
state |
String |
Definition: User status Value range:
Enumeration values:
|
|
service_license_status |
Integer |
Definition: Service-level permission status. 0: Disabled; 1: Enabled. Constraints: N/A. Value range: 1~2147483647 |
|
name_cn |
String |
Definition: Username in Chinese. Constraints: N/A. |
|
nick_name |
String |
Definition: User alias. Constraints: N/A. |
|
tenant_name |
String |
Definition: Tenant name. Constraints: N/A. |
Example Requests
Create a repository commit rule
POST /v4/repositories/{repository_id}/commit-rules
{
"binary_gate_enabled" : true,
"allowed_modify_binary" : true,
"max_file_size" : 50,
"effective_date" : null,
"privileged_user_ids" : [ 9124 ],
"name" : "fffffff2233",
"branch_name" : "mas1*"
}
Example Responses
Status code: 200
Repository commit rule
{
"id" : 169352,
"repository_id" : 2112035798,
"commit_message_regex" : "test",
"commit_message_negative_regex" : "test",
"prohibited_file_name_regex" : "test",
"author_email_regex" : "test",
"max_file_size" : 50,
"allowed_max_file_size" : 300,
"effective_date" : "2025-01-14T20:13:56.000+08:00",
"binary_gate_enabled" : true,
"privileged_users" : [ {
"id" : 9124,
"name" : "test_user",
"username" : "test_user",
"state" : "active",
"service_license_status" : null,
"name_cn" : "test_user",
"nick_name" : "beta_dv",
"tenant_name" : "test_tenant"
} ],
"allowed_modify_binary" : true,
"allowed_binary_file_name_regex" : "test",
"author_regex" : "test",
"name" : "2",
"branch_name" : "2",
"created_at" : "2025-06-20T17:37:55.000+08:00",
"updated_at" : "2025-06-20T17:37:55.000+08:00"
}
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
Repository commit rule |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot