MergeChangeRequest - Merge a merge request

Updated at:

Merges a merge request in a code repository.

Applicable editions

Central edition, Region edition

Endpoint and authorization information

  • Obtain the endpoint: Replace {domain} in the API request syntax.
  • Obtain a personal access token.
  • Obtain the organizationId: Required only for the Central edition. Go to the Basic Information page in the Organization Management console to retrieve your organization ID.

Product

Resource

Required permission

Code management

Merge request

Read and write

Request syntax

Central edition

POST https://{domain}/oapi/v1/codeup/organizations/{organizationId}/repositories/{repositoryId}/changeRequests/{localId}/merge

Region edition

POST https://{domain}/oapi/v1/codeup/repositories/{repositoryId}/changeRequests/{localId}/merge

Request headers

Parameter

Type

Required

Description

Example value

x-yunxiao-token

string

Yes

Personal access token.

pt-0fh3****0fbG_35af****0484

Request parameters

Parameter

Type

Location

Required

Description

Example value

organizationId

string

path

  • Yes: Central edition

  • No: Region edition

Organization ID.

60d54f3daccf2bbd6659f3ad

repositoryId

string

path

Yes

Repository ID or URL-encoded full path.

2813489 or 60de7a6852743a5162b5f957%2FDemoRepo

localId

integer

path

Yes

Local ID.

1

-

object

body

No

mergeMessage

string

body

No

Merge commit message.

merge message

mergeType

string

body

Yes

Merge type: ff-only – fast-forward-only merge; no-fast-forward – standard merge; squash – squash merge; rebase – rebase merge.

ff-only

removeSourceBranch

boolean

body

No

Whether to delete the source branch after merging.

true

Request examples

Central edition

curl -X 'POST' \
  'https://{domain}/oapi/v1/codeup/organizations/60d54f3daccf2bbd6659f3ad/repositories/2813489 or 60de7a6852743a5162b5f957%2FDemoRepo/changeRequests/1/merge' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
  --data '
    {
        "mergeMessage": "merge message",
        "mergeType": "ff-only",
        "removeSourceBranch": true
    }'

Region edition

curl -X 'POST' \
  'https://{domain}/oapi/v1/codeup/repositories/{repository_id_or_path}/changeRequests/1/merge' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
  --data '
    {
        "mergeMessage": "merge message",
        "mergeType": "ff-only",
        "removeSourceBranch": true
    }'

Response parameters

Parameter

Type

Description

Example value

-

object

ahead

integer

Number of commits by which the source branch is ahead of the target branch.

1

allRequirementsPass

boolean

Whether all required checks have passed.

true

author

object

User information.

avatar

string

Profile picture URL.

https://example/example/w/100/h/100

email

string

User email address.

username@example.com

name

string

User name.

codeup-name

state

string

User status: active – available; blocked – unavailable.

active

userId

string

Apsara DevOps user ID.

62c795xxxb468af8

username

string

Username for login.

codeup-username

behind

integer

Number of commits by which the target branch is ahead of the source branch.

1

canRevertOrCherryPick

boolean

Whether revert or cherry-pick is allowed.

true

conflictCheckStatus

string

Conflict detection status: CHECKING – checking; HAS_CONFLICT – has conflicts; NO_CONFLICT – no conflicts; FAILED – check failed.

NO_CONFLICT

createFrom

string

Creation source: WEB – created via web UI; COMMAND_LINE – created via command line.

WEB

createTime

string

Creation time.

2024-10-05T15:30:45Z

description

string

Description.

mr description

detailUrl

string

Merge request details URL.

https://example.com/example/example_demo/change/1

hasReverted

boolean

Whether the merge request has been reverted.

false

localId

integer

Local ID.

1

mergedRevision

string

Commit ID of the merged revision. Returned only when the merge request has been merged.

6da8c14b5a9102998148b7ea35f96507d5304f74

mrType

string

Merge request type: CODE_REVIEW – code review; REF_REVIEW – branch or tag review.

CODE_REVIEW

projectId

integer

Repository ID.

2813489

reviewers

array

List of reviewers.

-

object

avatar

string

Profile picture URL.

https://example/example/w/100/h/100

email

string

User email address.

username@example.com

hasCommented

boolean

Whether the reviewer has commented.

true

hasReviewed

boolean

Whether the reviewer has completed the review.

true

name

string

User name.

codeup-name

reviewOpinionStatus

string

Review opinion: PASS – approved; NOT_PASS – not approved.

PASS

reviewTime

string

Review time.

2024-10-05T15:30:45Z

state

string

User status: active – available; blocked – unavailable.

active

userId

string

Apsara DevOps user ID.

62c795xxxb468af8

username

string

Username for login.

codeup-username

sourceBranch

string

Source branch.

demo-branch

sourceProjectId

integer

Source repository ID.

2813489

status

string

Merge request status: UNDER_DEV – in development; UNDER_REVIEW – under review; TO_BE_MERGED – ready to merge; CLOSED – closed; MERGED – merged.

UNDER_REVIEW

subscribers

array

List of subscribers.

-

object

User information.

avatar

string

Profile picture URL.

https://example/example/w/100/h/100

email

string

User email address.

username@example.com

name

string

User name.

codeup-name

state

string

User status: active – available; blocked – unavailable.

active

userId

string

Apsara DevOps user ID.

62c795xxxb468af8

username

string

Username for login.

codeup-username

supportMergeFastForwardOnly

boolean

Whether fast-forward-only merge is supported.

true

targetBranch

string

Target branch.

master

targetProjectId

integer

Target repository ID.

2813489

targetProjectNameWithNamespace

string

Target repository name with the full namespace path.

60de7a6852743a5162b5f957 / DemoRepo (spaces around the slash)

targetProjectPathWithNamespace

string

Target repository path with the full namespace path.

60de7a6852743a5162b5f957/DemoRepo

title

string

Title.

mr title

totalCommentCount

integer

Total number of comments.

1

unResolvedCommentCount

integer

Number of unresolved comments.

1

updateTime

string

Update time.

2024-10-05T15:30:45Z

webUrl

string

URL of the merge request page.

https://example.com/example/example_demo/change/1

Response example

{
    "ahead": 1,
    "allRequirementsPass": true,
    "author": {
        "avatar": "https://example/example/w/100/h/100",
        "email": "username@example.com",
        "name": "codeup-name",
        "state": "active",
        "userId": "62c795xxxb468af8",
        "username": "codeup-username"
    },
    "behind": 1,
    "canRevertOrCherryPick": true,
    "conflictCheckStatus": "NO_CONFLICT",
    "createFrom": "WEB",
    "createTime": "2024-10-05T15:30:45Z",
    "description": "mr description",
    "detailUrl": "https://example.com/example/example_demo/change/1",
    "hasReverted": false,
    "localId": 1,
    "mergedRevision": "6da8c14b5a9102998148b7ea35f96507d5304f74",
    "mrType": "CODE_REVIEW",
    "projectId": 2813489,
    "reviewers": [
        {
            "avatar": "https://example/example/w/100/h/100",
            "email": "username@example.com",
            "hasCommented": true,
            "hasReviewed": true,
            "name": "codeup-name",
            "reviewOpinionStatus": "PASS",
            "reviewTime": "2024-10-05T15:30:45Z",
            "state": "active",
            "userId": "62c795xxxb468af8",
            "username": "codeup-username"
        }
    ],
    "sourceBranch": "demo-branch",
    "sourceProjectId": 2813489,
    "status": "UNDER_REVIEW",
    "subscribers": [
        {
            "avatar": "https://example/example/w/100/h/100",
            "email": "username@example.com",
            "name": "codeup-name",
            "state": "active",
            "userId": "62c795xxxb468af8",
            "username": "codeup-username"
        }
    ],
    "supportMergeFastForwardOnly": true,
    "targetBranch": "master",
    "targetProjectId": 2813489,
    "targetProjectNameWithNamespace": "60de7a6852743a5162b5f957 / DemoRepo (spaces around the slash)",
    "targetProjectPathWithNamespace": "60de7a6852743a5162b5f957/DemoRepo",
    "title": "mr title",
    "totalCommentCount": 1,
    "unResolvedCommentCount": 1,
    "updateTime": "2024-10-05T15:30:45Z",
    "webUrl": "https://example.com/example/example_demo/change/1"
}

Error codes

For more information, see the Error Code Center.