CreatePushRule - Create a push rule
Creates a push rule for a code repository via OpenAPI.
Applicable editions | Central edition, Region edition |
Service endpoint and authorization information
Get the service endpoint: Replace the `{domain}` placeholder in the request URL.
Obtain the organization ID: Required only for the Central edition. You can obtain the organization ID from the Basic Information page in the Organization Management Console.
Product | Resource | Required permission |
Code Management | Push rule | Read/write |
Request syntax
Central edition
POST https://{domain}/oapi/v1/codeup/organizations/{organizationId}/repositories/{repositoryId}/pushRulesRegion edition
POST https://{domain}/oapi/v1/codeup/repositories/{repositoryId}/pushRulesRequest headers
Parameter | Type | Required | Description | Example value |
x-yunxiao-token | string | Yes | Your personal access token. | pt-0fh3****0fbG_35af****0484 |
Request parameters
Parameter | Type | Location | Required | Description | Example value |
organizationId | string | path |
| The organization ID. | 60d54f3daccf2bbd6659f3ad |
repositoryId | string | path | Yes | The repository ID or the full path URL-encoded. | 2813489 or 60de7a6852743a5162b5f957%2FDemoRepo |
| - | object | body | No | ||
| ruleInfos | array | body | No | The list of push rules to create. | |
| - | object | body | No | ||
checkerName | string | body | No | The rule name. Valid values: CommitMessageChecker (commit message rule), CommitAuthorEmailChecker (commit email rule), CommitAuthorChecker (commit author check), CommitCommitterChecker (committer check), ForcePushChecker (force push check), CommitFilesChecker (commit file restriction rule), and ThirdPartyChecker (third-party validation rule). | CommitMessageChecker |
checkerType | string | body | No | The enforcement level: warn (show a warning but allow the push) or block (block the push). | warn |
extraMessage | string | body | No | This parameter is valid for commit message rules, commit email rules, author checks, committer checks, and force push blocks. Use it as follows: 1. For a commit message rule, provide a regular expression. 2. For a commit email rule, provide an email regular expression. 3. To block force pushes, set this to "disabled". 4. To enable author checks, set this to "on". Omit this parameter if not needed. 5. To enable committer checks, set this to "on". Omit this parameter if not needed. 6. For third-party validation rules, use an empty string. | username@example.com |
fileRuleRegexes | array[string] | body | No | Use this field only for commit file restrictions. Provide one or more regular expressions. | ["*.java"] |
thirdPartyTimeout | integer | body | No | Use this field only for third-party validation rules. The default timeout is 1000 ms. Keep the third-party service response time under 1 second. Do not increase the timeout value. | 1000 |
thirdPartyUrl | string | body | No | Use this field only for third-party validation rules. Specify the third-party validation endpoint. If Codeup cannot reach the third-party service over the network, the call fails. This is a common issue. | http://example.com/test |
Request examples
Central edition
curl -X 'POST' \
'https://{domain}/oapi/v1/codeup/organizations/60d54f3daccf2bbd6659f3ad/repositories/2813489or60de7a6852743a5162b5f957%2FDemoRepo/pushRules' \
-H 'Content-Type: application/json' \
-H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
--data '
{
"ruleInfos": [
{
"checkerName": "CommitMessageChecker",
"checkerType": "warn",
"extraMessage": "username@example.com",
"fileRuleRegexes": ["*.java"],
"thirdPartyTimeout": 1000,
"thirdPartyUrl": "http://example.com/test"
}
]
}'Region edition
curl -X 'POST' \
'https://{domain}/oapi/v1/codeup/repositories/2813489or60de7a6852743a5162b5f957%2FDemoRepo/pushRules' \
-H 'Content-Type: application/json' \
-H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
--data '
{
"ruleInfos": [
{
"checkerName": "CommitMessageChecker",
"checkerType": "warn",
"extraMessage": "username@example.com",
"fileRuleRegexes": ["*.java"],
"thirdPartyTimeout": 1000,
"thirdPartyUrl": "http://example.com/test"
}
]
}'Response parameters
Parameter | Type | Description | Example value |
| - | object | ||
createdAt | string | The time when the rule was created. | 2024-10-05T15:30:45Z |
id | integer | The primary key ID of the push rule. | 1 |
| ruleInfos | array | The list of created push rules. | |
| - | object | ||
checkerName | string | The rule name. Valid values: CommitMessageChecker (commit message rule), CommitAuthorEmailChecker (commit email rule), CommitAuthorChecker (commit author check), CommitCommitterChecker (committer check), ForcePushChecker (force push check), CommitFilesChecker (commit file restriction rule), and ThirdPartyChecker (third-party validation rule). | CommitMessageChecker |
checkerType | string | The enforcement level: warn (show a warning but allow the push) or block (block the push). | warn |
extraMessage | string | This parameter is valid for commit message rules, commit email rules, author checks, committer checks, and force push blocks. Use it as follows: 1. For a commit message rule, provide a regular expression. 2. For a commit email rule, provide an email regular expression. 3. To block force pushes, set this to "disabled". 4. To enable author checks, set this to "on". Omit this parameter if not needed. 5. To enable committer checks, set this to "on". Omit this parameter if not needed. 6. For third-party validation rules, use an empty string. | username@example.com |
fileRuleRegexes | array[string] | Use this field only for commit file restrictions. Provide one or more regular expressions. | ["*.java"] |
thirdPartyTimeout | integer | Use this field only for third-party validation rules. The default timeout is 1000 ms. Keep the third-party service response time under 1 second. Do not increase the timeout value. | 1000 |
thirdPartyUrl | string | Use this field only for third-party validation rules. Specify the third-party validation endpoint. If Codeup cannot reach the third-party service over the network, the call fails. This is a common issue. | http://example.com/test |
updatedAt | string | The time when the rule was last updated. | 2024-10-05T15:30:45Z |
Response example
{
"createdAt": "2024-10-05T15:30:45Z",
"id": 1,
"ruleInfos": [
{
"checkerName": "CommitMessageChecker",
"checkerType": "warn",
"extraMessage": "username@example.com",
"fileRuleRegexes": ["*.java"],
"thirdPartyTimeout": 1000,
"thirdPartyUrl": "http://example.com/test"
}
],
"updatedAt": "2024-10-05T15:30:45Z"
}Error codes
For more information about error codes, see the Error Code Center.