{"id":27404924,"url":"https://github.com/hamidrezasahraei/gitlabautocreateandassignmergerequest","last_synced_at":"2025-07-09T20:08:11.058Z","repository":{"id":131860022,"uuid":"471324427","full_name":"hamidrezasahraei/GitlabAutoCreateAndAssignMergeRequest","owner":"hamidrezasahraei","description":"A Kotlin Script which create merge request automatically and assign it to a developer for review based on a startegy(Currently Queue).","archived":false,"fork":false,"pushed_at":"2022-03-18T13:28:47.000Z","size":6,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T05:49:01.850Z","etag":null,"topics":["cicd","gitlab","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hamidrezasahraei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-03-18T10:26:58.000Z","updated_at":"2024-10-01T00:04:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"1153c1a1-7857-4d47-afb8-624db498485e","html_url":"https://github.com/hamidrezasahraei/GitlabAutoCreateAndAssignMergeRequest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hamidrezasahraei/GitlabAutoCreateAndAssignMergeRequest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamidrezasahraei%2FGitlabAutoCreateAndAssignMergeRequest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamidrezasahraei%2FGitlabAutoCreateAndAssignMergeRequest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamidrezasahraei%2FGitlabAutoCreateAndAssignMergeRequest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamidrezasahraei%2FGitlabAutoCreateAndAssignMergeRequest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hamidrezasahraei","download_url":"https://codeload.github.com/hamidrezasahraei/GitlabAutoCreateAndAssignMergeRequest/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamidrezasahraei%2FGitlabAutoCreateAndAssignMergeRequest/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264502621,"owners_count":23618658,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cicd","gitlab","kotlin"],"created_at":"2025-04-14T05:48:26.096Z","updated_at":"2025-07-09T20:08:11.045Z","avatar_url":"https://github.com/hamidrezasahraei.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gitlab Auto-Create And Assign MergeRequests\n\nThis Kotlin Script can be used in GitLab CI to create merge requests automatically and assign them to a developer for review based on a strategy(Currently it is using Queue).\nFor creating the merge requests it use the basic ideas from this [repo](https://github.com/tmaier/gitlab-auto-merge-request).\n## Instructions\n\n### 1) `CI_ACCESS_TOKEN`\n\nFirst, you should create a Gitlab private access token and set it to a variable with the name `CI_ACCESS_TOKEN`. This is necessary for being able to open merge requests from CI.\n\n### 2) Get and Set reviewers ID\nYou can retrieve the ID of project members with this call:\n```bash\ncurl --header \"PRIVATE-TOKEN: \u003cyour_access_token\u003e\" \"https://\u003cyour_giltab_host\u003e/api/v4/projects/\u003cyour_project_id\u003e/members/all\"\n```\nNotice that you should replace `\u003cyour_access_token\u003e`, `\u003cyour_giltab_host\u003e` and `\u003cyour_project_id\u003e` with the correspond values.\nAfter retrieving this list, You should create your reviewers Queue. You just need to set the IDs which can review the Merge Requests in variable `reviewerIDs`:\n\n```Kotlin\nval reviewerIDs = mutableListOf\u003cString\u003e(\"id1\",\"id2\")\n```\n\nFinally for this step you must set the first ID which should review to a variable named `CURRENT_REVIEWER_USER_ID` in Gitlab, This is necessary for assign the first merge requests, After doing this the script will handle the next reviewers itself.\n### 3) Add your own labels for Merge Requests\nYou can add your own label for merge requests in method `getProperLabels`, Please make sure that you created that labels in Gitlab before. There is a default label named `Developer Review` in the script.\n\n### 4) Prepare `.gitlab-ci.yml`\nFirst you need to install the requirements for this script, It needs `sdkman` and `kscript` to run. For doing this you can add these lines to the `before_script` section:\n\n```yaml\nbefore_script:\n  - curl -s \"https://get.sdkman.io\" | bash     # install sdkman\n  - source \"$HOME/.sdkman/bin/sdkman-init.sh\"  # add sdkman to PATH\n  - sdk install kotlin                        # install Kotlin\n  - sdk install kscript                       # install Kscript \n```\n\nYou should add a stage to your CI for opening merge requests, For example you can create a stage named `openMergeRequest` like this:\n```yaml\nstages:\n  - openMergeRequest\n  - otherStage1\n  - otherStage2\n```\n\nAfter doing this you should call this script in that stage, For example:\n\n```yaml\nstages:\n  - openMergeRequest\n  - otherStage1\n  - otherStage2\n\nOpen Merge Request:\n  stage: openMergeRequest\n  script:\n    - kscript GitlabAutoMRandAssign.kts # The name of the script\n```\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n## License\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhamidrezasahraei%2Fgitlabautocreateandassignmergerequest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhamidrezasahraei%2Fgitlabautocreateandassignmergerequest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhamidrezasahraei%2Fgitlabautocreateandassignmergerequest/lists"}