GitLab is a cloud-based DevOps platform that allows teams to plan work, collaborate on code development, build applications, and deploy applications. It provides various tools that cover the entire application development lifecycle. The features and functionalities provided by GitLab include version control, requirements management, project management, automated build generation, testing and release management, etc.
You can integrate GitLab with ServiceDesk Plus Cloud to implement software projects in GitLab via the change module in ServiceDesk Plus Cloud. You can also raise issues in GitLab based on the incident requests in ServiceDesk Plus Cloud.
The integration between GitLab and ServiceDesk Plus Cloud enables the following functionalities:
Automatically create a project in GitLab from a change request
View GitLab project on the respective change details page
Create an issue in GitLab from an incident request
To set up the integration, GitLab APIs are used to create scripts that can be used to configure and enable the required functionalities by creating necessary custom functions, triggers, custom module, change templates, and a custom menu.
GitLab uses personal access tokens to authenticate API calls.
You can create as many personal access tokens as you like.
In the top-right corner, select your avatar.
Select Edit profile.
On the left sidebar, select Access Tokens.
Enter a name and optional expiry date for the token.
Select the desired scopes.
Select Create personal access token.
Save the personal access token somewhere safe. After you leave the page, you no longer have access to the token.

To use the personal access token obtained from GitLab in custom scripts, a global variable must be created as described below:
Go to Setup > Developer Space > Global Variables.
Click New Group.
Provide a name and description.
Create the following variables and add the respective values.
|
Variable |
Value |
|
PersonalAccessToken |
Paste the personal access token copied from GitLab in Step 1. |
Finally, click Save.

Note: The variable names used here should match the names used in the custom functions. If you are using the default custom function scripts, use the names mentioned in the above table.
To automate project creation in GitLab via ServiceDesk Plus Cloud, create a custom function with GitLab APIs and invoke it in appropriate change requests via triggers.
Go to Setup > Developer Space > Custom Functions.
Click New custom function.
Provide a name and description for the custom function and copy the script below to the code editor.
Create a Project in GitLab from Change Request
Click, Save.

Go to Setup > Developer Space > Custom Modules.
Click New.
Under the Details tab, provide name and its plural form. A default API name will be generated. Click Save and go to the Fields tab.
Now a single-line, mandatory, unique field with name "Change Id". By default, the Gitlab Project Name field is included in the custom module.
Click Save.

Go to Setup > Automation > Triggers > Triggers for Changes.
Click New Trigger.
Provide a name and description for the change trigger.
Set Execute when a Change is to Edited.
Set Execute during to Anytime.
Configure the conditions when you want to create GitLab Project automatically. For example, you can configure the trigger to be applied when the change request is moved to the Implementation stage for specific change templates.
Select the custom function created for the trigger action.
Finally, click Save.
A project in GitLab will be created automatically from a change request when the conditions configured in the trigger are met. The project name will be the same as the name of the change request from which it was created.
You can view GitLab project in the respective change request from which it is created, by building functionality using custom widgets.
Go to Setup > Developer Space > Custom Widgets.
Click New Custom Widget.
Provide name and description.
Upload the custom widget file (.zip) downloaded from step 1.
Set the Hosting to Sigma Server.
Finally, click Save.

When a GitLab project is automatically created from a change request, a sub-tab showing the project details will be added to the configured change stage. You can customize the stage in which the tab appears by selecting your preferred stages by expanding the widget details under Setup > Developer Space > Custom Widgets.

Sample:


Go to Setup > Developer Space > Custom Functions.
Click New custom function.
Provide a name and description for the custom function and copy the script below to the code editor.
Create an Issue in GitLab from Incident Requests
Click, Save.

Go to Setup > Developer Space > Custom Menu > Custom Menu for Request.
Click Add on the top-right and click New Menu Group.
Provide a name and description for the menu group and set Status to Enable.
Click Save.

Click the name of the menu group created and click New Menu Item.
Provide a name and description for the menu item, configure necessary conditions and status, and add the custom function configured in step 4 as the action.
Finally, click Save.

With this configuration, an option to raise an issue in GitLab project will be available under the Custom Actions drop-down on the request details page. If an incident request is associated with a change request that is tied to a GitLab project, invoking this custom action will create an issue in the respective project; an error will be thrown in all other cases.
