GitLab to JSM Assets

GitLab to JSM Assets

GitLab to JSM Assets Integration Guide

This page explains how to use OnLink to import project (repository) data from GitLab into Jira Service Management Assets.

Overview

OnLink imports GitLab REST API responses into Jira Service Management Assets object types using mapping statements such as key:, map:, and config:. Use this pattern for GitLab resources such as projects, groups, users, and members. This works for both GitLab.com and GitLab Self-Managed / Dedicated instances.

The high-level process is:

  1. Create or confirm the target Assets schema and object type (for example, GitLab Project).

  2. Create a GitLab access token with the read_api scope.

  3. Configure an OnLink Assets Data Source that authenticates to GitLab with a bearer token.

  4. Set the API method and GitLab endpoint, add filters, then fetch sample data.

  5. Configure offset pagination so the full project list is retrieved.

  6. Map JSON fields from the GitLab response to Assets attributes.

  7. Run Get Data to validate the result, then run the import when the mapping is correct.

Prerequisites

  • A Jira Service Management Assets schema and object type for the data you want to import.

  • OnLink installed and available from Manage your apps.

  • A GitLab personal, group, or project access token with the read_api scope.

  • Permission in JSM Assets to configure data sources, mappings, and imports.

  • Your GitLab API base URL: https://gitlab.com/api/v4 for GitLab.com, or https://<your-gitlab-host>/api/v4 for Self-Managed.

Supported GitLab object types

The examples on this page use GitLab project data from the Projects API. The same pattern can be adapted for other GitLab resources, such as groups (/groups), users (/users), and project members (/projects/:id/members), by selecting the appropriate API endpoint and mapping the returned JSON fields to the matching Assets attributes.

1. Create the GitLab access token

GitLab supports several REST API authentication methods. For scheduled OnLink imports, use a personal access token, group access token or OAuth 2.0 access token.

Option A – Group access token (recommended for organizations)

  1. In GitLab, open the top-level group that contains the projects you want to import.

  2. Go to Settings > Access tokens and select Add new token.

  3. Enter a name (for example, onlink-assets-sync) and an expiration date.

  4. Set the role to Reporter (or higher if you plan to import project statistics).

  5. Select the read_api scope.

  6. Create the token, then copy and securely store it.

Option B – Personal access token

  1. In GitLab, select your avatar > Edit profile > Access tokens > Add new token.

  2. Enter a name and expiration date, select the read_api scope, and create the token.

  3. Copy and securely store the token. The import will only see projects this user can access.

Group access tokens are available on GitLab Self-Managed (all tiers) and on GitLab.com Premium and Ultimate. On GitLab.com Free, use a personal access token from a dedicated service user.

Use the token generated above in the OnLink connection.

2. Configure the OnLink data source

  1. In OnLink, add an Assets Data Source.

  2. Set Authentication Type to Bearer Token.

  3. Set the header name to Authorization.

  4. Paste the token generated in GitLab.

GitLab accepts personal, project, and group access tokens in the OAuth-compliant header, so the request is sent as:

Authorization: Bearer <your_access_token>

3. Configure the API method

Use a GET request to retrieve records from the GitLab List all projects API. For example, to fetch projects, configure the request as follows:

  1. Set Method to GET.

  2. Set URL to https://gitlab.com/api/v4/projects

  3. Leave Response data path empty.

  4. Leave the remaining configuration at the default values unless your GitLab endpoint requires additional parameters.

 

GET https://gitlab.com/api/v4/projects?membership=true

On GitLab.com, GET /projects without filters lists every project visible to the token, including public projects across all of GitLab.com. Always add membership=true, or use the group endpoint below, so you only import your organization’s projects.

Alternative: import all projects in a group

To import every project in a group and its subgroups, use the group projects endpoint with the group ID or URL-encoded group path:

GET https://gitlab.com/api/v4/groups/<group_id>/projects?include_subgroups=true

4. Fetch sample data

Save the connection, then run it to fetch sample values from GitLab. Use the returned sample JSON to confirm that the endpoint is correct and to identify the field names needed for mapping.

When inspecting the sample response, look for the field path that contains the value you want to import. For example, the project path appears as path_with_namespace, while the group it belongs to is nested under namespace (for example, namespace.full_path).

5. Configure offset pagination

The List all projects endpoint returns a paginated list. GitLab supports offset-based pagination for up to 50,000 projects, which covers most organizations.

Parameter / header

Purpose

Parameter / header

Purpose

page

Page number to return. Starts at 1 (default).

per_page

Number of records per page. Default is 20, maximum is 100. Set it to 100 to reduce the number of API calls.

x-next-page (response header)

Next page number. Empty on the last page.

x-total / x-total-pages (response headers)

Total number of records and pages. These may be omitted for very large result sets, so do not rely on them alone.

In the OnLink data source:

  • Set the pagination type to Offset / page number.

  • Set the page parameter to page, starting at 1.

  • Set the page size parameter to per_page with a value of 100.

  • Set Max pages to cover your expected project count (for example, 10 pages × 100 = 1,000 projects). Increase it if you have more projects.

  • Pagination stops when a page returns an empty array ([]) or x-next-page is empty.

Always add a stable sort order so records do not shift between pages while the import runs:

GET https://gitlab.com/api/v4/projects?membership=true&order_by=id&sort=asc&per_page=100&page=1

If you need more than 50,000 projects, switch to GitLab keyset pagination (pagination=keyset&order_by=id&sort=asc) and follow the Link response header. See GitLab pagination.

6. Apply filtering

You can refine results by adding query parameters to the URL. Useful filters for the List all projects endpoint include:

Filter

Example

Use

Filter

Example

Use

membership

membership=true

Only projects the token user is a member of. Recommended on GitLab.com.

archived

archived=false

Exclude archived projects.

active

active=true

Only projects that are not archived and not marked for deletion.

visibility

visibility=private

Limit to public, internal, or private projects.

min_access_level

min_access_level=30

Only projects where the token user has at least this role (30 = Developer, 40 = Maintainer, 50 = Owner).

last_activity_after

last_activity_after=2026-01-01T00:00:00Z

Only projects with activity after this ISO 8601 date. Useful for excluding stale repositories.

updated_after

updated_after=2026-10-01T00:00:00Z&order_by=updated_at

Incremental syncs. Requires order_by=updated_at.

search

search=onlink

Match project name, path, or description (case-insensitive).

topic

topic=production,backend

Only projects tagged with all listed topics.

with_programming_language

with_programming_language=Java

Only projects using the given language.

statistics

statistics=true

Adds repository size and commit count. Requires Reporter role or higher.

For example, to import only active private projects you are a member of:

GET https://gitlab.com/api/v4/projects?membership=true&active=true&visibility=private&order_by=id&sort=asc&per_page=100

7. Configure the Assets import and mapping

After the connection is established, create the Assets import by following the JSM Assets Data Synchronization guide.

Use the fetched API sample to identify the GitLab JSON field names and map them to the corresponding JSM Assets attributes. The key: mapping should identify the stable unique value used to match and update existing Assets objects. Use the numeric project id, because project names and paths can change when a project is renamed or transferred.

Suggested GitLab Project object type

Mapping or setting

Assets attribute type

Purpose and usage

Mapping or setting

Assets attribute type

Purpose and usage

key:id=ProjectID

Integer

The key prefix defines the unique identifier. GitLab’s project id maps to the ProjectID attribute, so future syncs update existing objects instead of creating duplicates.

map:name=Name

Text (label)

The map prefix connects a source field to an Assets attribute. Syntax: map:[GitLab_Field]=[Assets_Attribute].

map:path_with_namespace=Full Path

Text

Full project path, for example onward/onlink/connector. Useful for search.

map:description=Description

Textarea

Project description.

map:web_url=URL

URL

Link to open the project in GitLab.

map:http_url_to_repo=Clone URL

Text

HTTPS clone URL of the repository.

map:visibility=Visibility

Select (Private, Internal, Public)

Supports security reviews, for example finding public repositories.

map:default_branch=Default Branch

Text

Default branch, for example main.

map:archived=Archived

Boolean

Whether the project is archived.

map:empty_repo=Empty Repository

Boolean

Flags projects with no code, useful for cleanup.

map:created_at=Created Date

DateTime

When the project was created.

map:last_activity_at=Last Activity

DateTime

Last project activity. GitLab updates this at most once per hour.

map:open_issues_count=Open Issues

Integer

Number of open issues.

map:star_count=Stars / map:forks_count=Forks

Integer

Popularity and reuse indicators.

map:namespace.full_path=Namespace

Text

Group or user namespace that owns the project. Values are nested under namespace.

map:namespace.id=Group|GroupID=${namespace.id}

Object reference (GitLab Group)

Creates a reference to a GitLab Group object whose GroupID matches the project’s namespace ID. If the referenced object does not exist, OnLink can create it with config:enable_object_creation=true, or you can suppress creation with |create=false.

map:creator_id=Created By|GitLabUserID=${creator_id}

Object reference (GitLab User)

Links the project to the GitLab User object that created it. Import users first from /users if you use this mapping.

map:topics=Topics|Name=${topics}

Object reference, multiple

Maps array values from topics to referenced Topic objects. Configure the Assets attribute cardinality to allow multiple values.

map:statistics.repository_size=Repository Size

Integer

Repository size in bytes. Only returned when the URL includes statistics=true.

Sample JSON Response

[ { "id": 4, "description": "string", "name": "string", "name_with_namespace": "string", "path": "string", "path_with_namespace": "string", "created_at": "2026-01-15T13:46:02Z", "updated_at": "2026-10-30T09:12:44Z", "default_branch": "main", "topics": [ "string" ], "ssh_url_to_repo": "string", "http_url_to_repo": "string", "web_url": "string", "readme_url": "string", "avatar_url": "string", "forks_count": 0, "star_count": 0, "last_activity_at": "2026-10-30T17:11:26.841Z", "visibility": "private", "namespace": { "id": 3, "name": "string", "path": "string", "kind": "group", "full_path": "string", "parent_id": null, "avatar_url": "string", "web_url": "string" }, "empty_repo": false, "archived": false, "creator_id": 1, "open_issues_count": 0, "issues_enabled": true, "merge_requests_enabled": true, "wiki_enabled": true, "jobs_enabled": true, "shared_runners_enabled": true, "lfs_enabled": true, "import_status": "none", "compliance_frameworks": [], "statistics": { "commit_count": 0, "storage_size": 0, "repository_size": 0 }, "_links": { "self": "string", "issues": "string", "merge_requests": "string", "repo_branches": "string", "members": "string" }, "permissions": { "project_access": null, "group_access": null } } ]

Mapping guidance

  • Start with one unique key: mapping (id) so OnLink can identify whether to create or update an Assets object.

  • Add map: entries for each GitLab field you want to store in Assets.

  • Compare the GitLab sample JSON with the Assets object type attributes before running an import.

  • Fields returned can vary with the token’s role. Some fields only appear for Maintainers or Owners, and simple=true returns a reduced field set, so confirm fields in the sample response before mapping them.

  • If a value is nested in the JSON response (for example, namespace.full_path), inspect the sample output carefully and use the field path supported by the OnLink mapping configuration.

8. Validate and run the import

  1. Use Get Data first to preview the data returned by GitLab.

  2. Confirm that the sample records contain the expected fields and values, and that only your organization’s projects are returned.

  3. Verify that the key field maps to a unique Assets attribute.

  4. Check the record count against GitLab to confirm pagination retrieved every page.

  5. Review the object type mapping and attribute names for spelling and case consistency.

  6. Run the import only after the previewed data and mapping are correct.

Troubleshooting

Response

Likely cause and fix

Response

Likely cause and fix

401 Unauthorized

Token is missing, expired, or revoked. Create a new token and update the data source.

403 insufficient_scope

Token lacks the required scope. Recreate it with read_api.

429 Too Many Requests

GitLab rate limit reached. Reduce Max pages or the sync frequency, and use per_page=100 to cut the number of calls.

Thousands of unexpected projects

The URL is missing membership=true on GitLab.com. Add it, or switch to the group projects endpoint.