Problem to solve
I create a merge request from my CI job using the REST API. This works correctly and I get a response containing the MR’s iid.
I then try to use the (PUT) API to set the merge_when_pipeline_succeeds=true
flag for this MR. This works when I use my own personal access token, but if I use a project access token (with the same privileges), it fails with a 405 Method not allowed
error.
The same token works for creating the merge request and for fetching merge request details.
Steps to reproduce
I followed instructions from Merge requests API | GitLab and made the following request:
curl --header "PRIVATE-TOKEN: glpat-********" -v -X PUT "$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests/$MR_IID/merge?merge_when_pipeline_succeeds=true"
This works when I provide my own PRIVATE_TOKEN
but does not work when I provide a project access token.
I’ve verified that the user associated with the project access token does have permissions to merge to the target branch.
Configuration
NA
Versions
Please select whether options apply, and add the version information.
- Self-managed
-
GitLab.com
SaaS - Dedicated
- Self-hosted Runners
Versions
- GitLab (Web:
/help
or self-managed system informationsudo gitlab-rake gitlab:env:info
): - GitLab Runner, if self-hosted (Web
/admin/runners
or CLIgitlab-runner --version
):