UpdatePushRule

Updated at:

Updates a specified push rule by overwriting the existing configuration. If you add a new rule item, ensure that the original rule items are also included. Otherwise, the original items are overwritten by the new content.

Operation description

Requires the permissions of a repository administrator 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

PUT /api/v4/projects/{repositoryId}/push_rule/{pushRuleId} HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

repositoryId

integer

Yes

The repository ID.

2709413

pushRuleId

integer

Yes

The push rule ID.

2077

Request parameters

Parameter

Type

Required

Description

Example

organizationId

string

Yes

The organization ID in string format. You can obtain the ID from the Yunxiao URL, such as https://devops.aliyun.com/organization/[OrganizationId].

5ebbc0228123212b59xxxxx

accessToken

string

No

The personal access token. This parameter is not required if you use an Alibaba Cloud AccessKey pair or Security Token Service (STS) for temporary authorization.

f0b1e61db5961df5975a93f9129d2513

body

object

No

The request body.

ruleInfos

array<object>

No

The list of rule information.

object

No

The rule information.

checkerName

string

No

The rule name. Valid values:

  • CommitMessageChecker: Commit message rule.

  • CommitAuthorEmailChecker: Commit email rule.

  • CommitAuthorChecker: Commit author check.

  • CommitCommitterChecker: Committer check.

  • ForcePushChecker: Force push prevention check.

  • CommitFilesChecker: Commit file restriction rule.

CommitAuthorChecker

extraMessage

string

No

The extra message. This parameter is valid for commit message, commit email, author check, committer check, and force push prevention rules:

  • For the commit message rule, set extraMessage to the regular expression used for checking.

  • For the commit email rule, set extraMessage to the regular expression used for checking emails.

  • For the force push prevention rule, set extraMessage to "disabled".

  • For the author check rule, set extraMessage to "on". Leave this parameter empty if the check is not required.

  • For the committer check rule, set extraMessage to "on". Leave this parameter empty if the check is not required.

on

checkerType

string

No

The restriction level for code owner checks. This parameter is valid only for the author check and committer check rules. You do not need to specify this parameter for other rules. Valid values:

  • warn: Issues a warning only and allows the push.

  • block: Blocks the push.

warn

fileRuleRegexes

array

No

The regular expressions for commit file restrictions. This parameter is valid only for the commit file restriction rule. You can specify multiple regular expressions.

string

No

The regular expression for file restrictions.

\.java$

Response elements

Element

Type

Description

Example

object

Schema of Response

requestId

string

The request ID.

ASSDS-ASSASX-XSAXSA-XSAXSAXS

errorCode

string

The error code.

Openapi.RequestError

errorMessage

string

The error message.

""

success

boolean

Indicates whether the request is successful.

true

result

object

The returned result.

id

integer

The push rule ID.

30815

ruleInfos

array<object>

The list of rule information.

object

The rule information.

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 prevention check.

  • CommitFilesChecker: Commit file restriction rule.

CommitAuthorChecker

checkerType

string

The restriction level for code owner checks. This parameter is valid only for the author check and committer check rules. You do not need to specify this parameter for other rules. Valid values:

  • warn: Issues a warning only and allows the push.

  • block: Blocks the push.

warn

extraMessage

string

The extra message. This parameter is valid for commit message, commit email, author check, committer check, and force push prevention rules:

  • For the commit message rule, set extraMessage to the regular expression used for checking.

  • For the commit email rule, set extraMessage to the regular expression used for checking emails.

  • For the force push prevention rule, set extraMessage to "disabled".

  • For the author check rule, set extraMessage to "on". Leave this parameter empty if the check is not required.

  • For the committer check rule, set extraMessage to "on". Leave this parameter empty if the check is not required.

on

fileRuleRegexes

array

The regular expressions for commit file restrictions. This parameter is valid only for the commit file restriction rule. You can specify multiple regular expressions.

string

The regular expression for file restrictions.

\.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": "Openapi.RequestError",
  "errorMessage": "\"\"",
  "success": true,
  "result": {
    "id": 30815,
    "ruleInfos": [
      {
        "checkerName": "CommitAuthorChecker",
        "checkerType": "warn",
        "extraMessage": "on",
        "fileRuleRegexes": [
          "\\.java$"
        ]
      }
    ],
    "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.