CreatePushRule

Updated at:

Create a push rule.

Operation description

You must have repository administrator permissions or higher.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request syntax

POST /api/v4/projects/{repositoryId}/push_rule HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

repositoryId

integer

Yes

The repository ID.

187687

Request parameters

Parameter

Type

Required

Description

Example

organizationId

string

Yes

The organization ID. You can get this ID from your Alibaba Cloud DevOps URL, for example: https://devops.aliyun.com/organization/{OrganizationId}.

5ebbc0228123212b59xxxxx

accessToken

string

No

The personal access token. This parameter is not required if you authenticate by using an Alibaba Cloud AccessKey pair or STS temporary authorization.

f0b1e61db5961df5975a93f9129d2513

body

object

No

The request body.

ruleInfos

array<object>

Yes

A list of rule objects.

object

No

A rule object.

checkerName

string

No

The name of the rule. Valid values:

  • CommitMessageChecker: A commit message rule.

  • CommitAuthorEmailChecker: A commit author email rule.

  • CommitAuthorChecker: A commit author rule.

  • CommitCommitterChecker: A commit committer rule.

  • ForcePushChecker: A rule that disallows force pushes.

  • CommitFilesChecker: A commit file restriction rule.

CommitMessageChecker

extraMessage

string

No

The behavior of this parameter varies based on the value of checkerName.

  • For the CommitMessageChecker rule, provide a regular expression to validate commit messages.

  • For the CommitAuthorEmailChecker rule, provide a regular expression to validate author email addresses.

  • For the ForcePushChecker rule, provide the value "disabled" to disallow force pushes.

  • For the CommitAuthorChecker rule, provide the value "on" to enable the check. Omit this parameter if the check is not required.

  • For the CommitCommitterChecker rule, provide the value "on" to enable the check. Omit this parameter if the check is not required.

user@example.com

checkerType

string

No

Specifies the enforcement level for a code ownership check. This parameter is valid only for CommitAuthorChecker and CommitCommitterChecker. Valid values:

  • warn: Displays a warning but allows the push.

  • block: Blocks the push and returns an error.

warn

fileRuleRegexes

array

No

An array of regular expressions to restrict file paths. This parameter is used only when checkerName is CommitFilesChecker.

string

No

A regular expression to restrict file paths.

\.java$

Response elements

Element

Type

Description

Example

object

The response schema.

requestId

string

The request ID.

ASSDS-ASSASX-XSAXSA-XSAXSAXS

errorCode

string

The error code.

""

errorMessage

string

The error message.

""

success

boolean

Indicates whether the request was successful.

true

result

object

The result.

id

integer

The push rule ID.

2077

ruleInfos

array<object>

The list of rules.

object

Information about a single rule.

checkerName

string

The rule name. Valid values:

  • CommitMessageChecker: commit message rule

  • CommitAuthorEmailChecker: commit author email rule

  • CommitAuthorChecker: commit author check

  • CommitCommitterChecker: committer check

  • ForcePushChecker: force push check

  • CommitFilesChecker: commit file limit rule

ForcePushChecker

checkerType

string

The enforcement level. This parameter applies only to the commit author check and committer check rules. Valid values:

  • warn: Warns the user and allows the push.

  • block: Blocks the push.

warn

extraMessage

string

Additional information about the rule. The value of this parameter depends on the value of checkerName:

  • For the commit message rule, this parameter contains the validation regular expression.

  • For the commit author email rule, this parameter contains the regular expression for the email address.

  • For the force push check, this parameter is set to disabled.

  • For the commit author check, the value is on if the check is enabled.

  • For the committer check, the value is on if the check is enabled.

disabled

fileRuleRegexes

array

An array of regular expressions for the commit file limit rule. Multiple expressions are supported.

string

A regular expression used for restricting files.

\.java$

gmtCreate

string

The creation time.

2023-09-03T18:20:06+08:00

gmtModified

string

The modification time.

2023-09-03T18:20:06+08:00

Examples

Success response

JSON format

{
  "requestId": "ASSDS-ASSASX-XSAXSA-XSAXSAXS",
  "errorCode": "\"\"",
  "errorMessage": "\"\"",
  "success": true,
  "result": {
    "id": 2077,
    "ruleInfos": [
      {
        "checkerName": "ForcePushChecker",
        "checkerType": "warn",
        "extraMessage": "disabled",
        "fileRuleRegexes": [
          "\\.java$\n"
        ]
      }
    ],
    "gmtCreate": "2023-09-03T18:20:06+08:00",
    "gmtModified": "2023-09-03T18:20:06+08:00"
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.