Published on: October 8, 2024
4 min read
Learn how to improve GitLab extensibility and integration with external applications in this demo. The result: a seamless integration that provides more control over merge requests.
GitLab customers often ask how to connect merge requests to external applications, such as ServiceNow or custom-built applications, to control approvals for the merging of code into a target branch from these external systems. To address this need, GitLab offers External Status Check, a powerful feature that allows the sending of API calls to external systems to request the status of an external requirement, providing seamless integration and control over your merge requests.
In this article, I'll demonstrate this feature by explaining how to deploy an application I developed. The application is designed to receive status check requests from GitLab Merge Requests, list them, and enable external users to approve/reject these requests without logging in to the GitLab console. As a result, GitLab platform architects will better understand GitLab extensibility and integration with external systems.
The provided sample application can:
KUBE_CONTEXT
, with the value equal to the used agent path:name, similar to the following structure path/to/agent/project:agent-name
.approval-app
namespace by default.approval-app
namespace in the target Kubernetes cluster.gitlab-token
with the value set to the personal access token (PAT) of the user who will be approving the requests. The approval application will use this PAT to communicate back to the GitLab instance.kubectl get services -n approval-app
.EXTERNAL-IP
with the value of the external IP address from the previous step. The resulting page should look like below (the table would be empty as we have not added any new merge requests yet).[http://EXTERNAL-IP[/approval-apps/status_check
. Replace the EXTERNAL-IP
with the external IP address found in the previous steps.Target Branch
to the default, or select branch if you want this check to be triggered only for merge requests against certain branches.HMAC Shared Secret
as it is and click Add status check.1 Pending
.EXTERNAL-IP
with the value of the external IP address from the previous steps): http://EXTERNAL-IP/approval-apps/
.Use the following notes to debug if something does not go as planned:
It is always helpful to view the logs for the external status check application. To do so:
kubectl get pods -n approval-app
.kubectl logs [THE NAME OF THE POD] -n approval-app
.You can SSH into the application pod and view the database (Alchemydb), which is used for the application.
kubectl exec -it \[POD-NAME\] -n approval-app -- /bin/sh
cd instance
sqlite3 gitlab_status_checks.db
.tables
.PRAGMA table_info('status_check');
.status_check
table, type select * from status_check
.Discover more about GitLab External Status Check and how to gain more control over merge requests.