A Kotlin Script which Auto-Create And Assign Gitlab MergeRequests

Overview

Gitlab Auto-Create And Assign MergeRequests

This 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). For creating the merge requests it use the basic ideas from this repo.

Instructions

1) CI_ACCESS_TOKEN

First, 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.

2) Get and Set reviewers ID

You can retrieve the ID of project members with this call:

" "https:// /api/v4/projects/ /members/all"">
curl --header "PRIVATE-TOKEN: 
     
      "
      "https://
     
      /api/v4/projects/
      
       /members/all
       "
      
     

Notice that you should replace , and with the correspond values. After 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:

val reviewerIDs = mutableListOf<String>("id1","id2")

Finally 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.

3) Add your own labels for Merge Requests

You 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.

4) Prepare .gitlab-ci.yml

First 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:

before_script:
  - curl -s "https://get.sdkman.io" | bash     # install sdkman
  - source "$HOME/.sdkman/bin/sdkman-init.sh"  # add sdkman to PATH
  - sdk install kotlin                        # install Kotlin
  - sdk install kscript                       # install Kscript 

You should add a stage to your CI for opening merge requests, For example you can create a stage named openMergeRequest like this:

stages:
  - openMergeRequest
  - otherStage1
  - otherStage2

After doing this you should call this script in that stage, For example:

stages:
  - openMergeRequest
  - otherStage1
  - otherStage2

Open Merge Request:
  stage: openMergeRequest
  script:
    - kscript GitlabAutoMRandAssign.kts # The name of the script

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

You might also like...
An attempt to create the opensource clone for the Calibre APP in Kotlin multiplatform
An attempt to create the opensource clone for the Calibre APP in Kotlin multiplatform

CalibreKMM An attempt/research clone for calibre app written in kotlin multiplatform. Plan to target Desktop JVM with (Jetpack Compose) TODOs Koin doe

Small app to create icon sets for Linux, Windows, OSX, Android and IOS from a single PNG image

FXIconcreator Small app to create icon sets (multi resolution) for Linux, Windows, OSX from a single PNG image Reason for creating such an app was tha

The Klutter CLI tool gives access to all tasks to create and manage a Klutter project.

Klutter CLI The Klutter CLI tool gives access to all tasks to create and manage a Klutter project. Gettings started Download the tool. Unzip the file.

With MaterialTimelineView you can easily create a material looking timeline.
With MaterialTimelineView you can easily create a material looking timeline.

MaterialTimelineView With MaterialTimelineView you can easily create a material looking timeline. Setup The library is pushed to jCenter() as an AAR,

Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager.
Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager.

Carousel Recyclerview Create carousel effect in recyclerview with the CarouselRecyclerview in a simple way. Including in your project Gradle Add below

Create minecraft worlds without lag!

WorldGen 랙 없는 월드 생성을 위한 라이브러리 시작하기에 앞서, 이 라이브러리는 UHC_System 의 월드 생성 코드를 작성하면서 WorldCreator의 단점인 랙을 없애기 위해 만들어진 코드의 일부를 라이브러리로 공개하는 것임을 알려드립니다 WorldCre

Stateful is a Kotlin library which makes Android application development faster and easier.

Stateful Stateful is a Kotlin library which makes Android application development faster and easier. It helps you delete all the boilerplate code for

Kotlin and Ktor app, which can easily be deployed to Heroku

[ 🚧 Work in progress 👷‍♀️ ⛏ 👷 🔧️ 👷 🔧 🚧 ] Shoppe Kotlin Multiplatform App Kotlin and Ktor app, which can easily be deployed to Heroku. This appl

Kotlin Multiplatform is an SDK for cross-platform mobile development, which enables teams to use the same business logic in both Android and iOS client applications.
Kotlin Multiplatform is an SDK for cross-platform mobile development, which enables teams to use the same business logic in both Android and iOS client applications.

Kotlin Multiplatform is an SDK for cross-platform mobile development, which enables teams to use the same business logic in both Android and iOS client applications.

Owner
Hamidreza Sahraei
Android Developer
Hamidreza Sahraei
A composite Github Action to execute the Kotlin Script with compiler plugin and dependency caching!

Kotlin Script Github Action Kotlin can also be used as a scripting language, which is more safer, concise, and fun to write than bash or python. Githu

Suresh 9 Nov 28, 2022
Run shell commands from a Kotlin script or application with ease

Run shell commands from a Kotlin script or application with ease. Turtle simplifies the process of running external commands and processes from your K

Andrew Lord 187 Jan 9, 2023
Auto-generate the fastest possible Parcelable implementations for Java and Kotlin

This project is deprecated It will still be maintained, but no new features will be added. Please use Parcelize, as it is the official way of generati

Bradley Campbell 492 Nov 17, 2022
Recycler-coroutines - RecyclerView Auto Add Data Using Coroutines

Sample RecyclerView Auto Add With Coroutine Colaborator Very open to anyone, I'l

Faisal Amir 8 Dec 1, 2022
Create an application with Kotlin/JVM and Kotlin/JS, and explore features around code sharing, serialization, server- and client

Practical Kotlin Multiplatform on the Web 본 저장소는 코틀린 멀티플랫폼 기반 웹 프로그래밍 워크숍(강좌)을 위해 작성된 템플릿 프로젝트가 있는 곳입니다. 워크숍 과정에서 코틀린 멀티플랫폼을 기반으로 프론트엔드(front-end)는 Ko

SpringRunner 14 Nov 5, 2022
Create an application with Kotlin/JVM and Kotlin/JS, and explore features around code sharing, serialization, server- and client

Building a Full Stack Web App with Kotlin Multiplatform 본 저장소는 INFCON 2022에서 코틀린 멀티플랫폼 기반 웹 프로그래밍 핸즈온랩을 위해 작성된 템플릿 프로젝트가 있는 곳입니다. 핸즈온 과정에서 코틀린 멀티플랫폼을

Arawn Park 19 Sep 8, 2022
Kotlin DALL·E 2 is a new AI system that can create realistic images and art from a description in natural language.

OpenAI Dall•E AI Kotlin Mobile App OpenAI Dall•E Application Build With Kotlin MVVM (Model - View - ViewModel) Clean Architecture, Beautiful Design UI

Murat ÖZTÜRK 15 Jan 1, 2023
🛠️ The missing drawable toolbox for Android. Create drawables programmatically and get rid of the boring and always repeated drawable.xml files.

DrawableToolbox English | 中文 The missing DrawableToolbox for Android. Create drawables programmatically and get rid of the boring and always repeated

Hong Duan 1.1k Jan 4, 2023
Create kotlin android project with one line of command.

README This is an android application template project built with kotlin language and some useful libraries. It provides a creator script to quickly c

nekocode 1.6k Dec 20, 2022
A react-like kotlin library to create an inventory ui easily in paper plugins

A react-like kotlin library to create an inventory ui easily in paper plugins

R2turnTrue 6 Aug 23, 2022