GitLab API integration with website

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Integrating GitLab API with Website

GitLab API is used for CI/CD integrations, displaying pipeline status, managing tasks from external systems, and authorization via GitLab OAuth. Particularly relevant for DevOps tools and corporate portals.

Authentication

import gitlab

# Personal Access Token
gl = gitlab.Gitlab('https://gitlab.com', private_token=GITLAB_TOKEN)

# OAuth2 for user applications
gl = gitlab.Gitlab('https://gitlab.com', oauth_token=oauth_token)

Common Scenarios

CI/CD Pipeline Status on Website:

def get_pipeline_status(project_id: int, ref: str = 'main') -> dict:
    project   = gl.projects.get(project_id)
    pipelines = project.pipelines.list(ref=ref, per_page=1)

    if not pipelines:
        return {'status': 'unknown'}

    pipeline = pipelines[0]
    return {
        'status':     pipeline.status,      # success/failed/running/pending
        'ref':        pipeline.ref,
        'sha':        pipeline.sha[:8],
        'started_at': pipeline.started_at,
        'duration':   pipeline.duration,
        'url':        pipeline.web_url,
    }

Trigger Pipeline from Admin Panel:

public function triggerDeploy(Request $request): JsonResponse
{
    $resp = Http::withToken(config('services.gitlab.token'))
        ->post("https://gitlab.com/api/v4/projects/{$projectId}/pipeline", [
            'ref'       => 'main',
            'variables' => [
                ['key' => 'DEPLOY_ENV', 'value' => $request->environment],
            ],
        ]);

    return response()->json(['pipeline_id' => $resp->json('id')]);
}

GitLab OAuth2

Route::get('/auth/gitlab/redirect', function () {
    return redirect('https://gitlab.com/oauth/authorize?' . http_build_query([
        'client_id'     => config('services.gitlab.client_id'),
        'redirect_uri'  => route('auth.gitlab.callback'),
        'response_type' => 'code',
        'scope'         => 'read_user read_api',
    ]));
});

Webhooks

GitLab supports Push Events, Pipeline Events, Merge Request Events. Verification via X-Gitlab-Token header (secret token set during webhook creation).

Timeline

Displaying pipeline status + OAuth: 2–3 business days. Full integration with management: 4–5 days.