My earlier post on Jenkins Pipeline Groovy script - Part 1 , discusses about how to create Gitlab group using Jenkins Pipeline Groovy script. In this post, I am discussing about how to add list of Users to newly created Gitlab group or existing group with specific permission granted to them. In companies while handling big projects and maintaining enormous code repositories, it is very much important to know what permissions supposed to be given to each member in the team.

Because giving wrong permission to team member, opens big path for problems if the team member really unaware about how efficiently the permission can be used for good purpose. Hence giving right permissions to the team member is very serious business for quick and reliable delivery. And yes, this also avoids team member intervening unnecessarily to the projects where they do not actually belong.

1. Gitlab User Restful API

Gitlab exposes it’s functionality via Restful APIs which can be consumed via curl script or any programming language like Groovy and Python., etc. To add user to Gitlab group, Gitlab Project members Restful APIs are consumed in this tutorial.

Adding group members to GitHub

So who are Users in Gitlab Project, Users are team members who work on code level changes as developer or owner to the specific Gitlab project repositories or can even play any role(mentioned section 1.1) depending on the project requirement.

1.1 Gitlab User Permission Level

Based on the responsibility and the role of the team members assigned in the project level, Gitlab offers following member permissions level.

  • Guest (10)
  • Reporter (20)
  • Developer (30)
  • Maintainer (40)
  • Owner (50)

Though the permission level varies for different role, all the users have permission to clone or download the project code, leave the comments and create the issues in Gitlab Project where they belong. suppose, if any of the team member leaves the project, merge request and created issues will be unassigned automatically.

2. Pipeline Groovy script to add user to Gitlab group

So how to add users to Gitlab group, my earlier post on Jenkins Pipeline Groovy script - Part 1, discusses on how to create Gitlab group using Pipeline Groovy script. Here I am explaining about how to add team members to a newly created Gitlab group or existing group. Let’s create groovy class with name addUserToGitlabGroup.groovy

What is this groovy class does:

  • Checks whether the user has access to Gitlab URL instance or not
  • Only if the user has access, then adds the user to mentioned Gitlab group with given access level

#groovy #gitlab #jenkins ci #jenkins automation #jenkins

Jenkins Pipeline Groovy script - Part 2 Add a User to a Gitlab Group
8.05 GEEK