GitLab vendor logo

Vendor

GitLab

Product

Method

REST

Category

CI/CD

Project Type

Workflow Project


View Repository
Workflow

GitLab - Modular Automations

Overview

The integration of Itential and GitLab enables network teams to utilize GitLab's REST API to build automations that can include common tasks for version control of assets. This is a library of related automations that can be used as modular components in your own larger, end-to-end workflows.

Workflows

Name Overview
Create Branch - GitLab - REST Workflow to create a new branch for an existing repository in GitLab.
Create Merge Request - GitLab - REST Workflow that creates a new merge request for an existing branch in GitLab.
Create Project - GitLab - REST This workflow creates a new GitLab repository with or without using a template.
Get Branch - GitLab - REST Workflow to get a branch for an existing repository in GitLab.
Get Diff for Merge - GitLab - REST Workflow that gets a diff for a merge request in GitLab.
Get File - GitLab - REST Workflow that get a file from a repository in GitLab.
Push Commit to Branch - GitLab - REST Push a commit to a branch in Gitlab
Update Project Variables - GitLab - REST Workflow to update CI/CD variables in GitLab

For further technical details on how to install and use this Workflow Project, please click the Technical Documentation tab.

Table of Contents

Getting Started

This section is helpful for deployments as it provides you with pertinent information on prerequisites and properties.

Helpful Background Information

Workflows often include logic that varies from business to business. As a result, we often find that our Workflow Projects are more useful as modular components that can be incorporated into a larger process. In addition, they often can add value as a learning tool on how we integrate with other systems and how we do things within the Itential Automation Platform.

While these can be utilized, you may find more value in using them as a starting point to build around.

Prerequisites

Itential Workflow Projects are built and tested on particular versions of IAP. In addition, Workflow Projects are often dependent on external systems and as such, these Workflow Projects will have dependencies on these other systems. This version of GitLab - REST has been tested with:

  • IAP 2023.2

External Dependencies

Name OS Version API Version
Gitlab 16.8

Adapters

Name Version Configuration Notes
adapter-gitlab 0.13.1

How to Install

To install the Workflow Project:

  • Verify you are running a supported version of the Itential Automation Platform (IAP) as listed above in the Supported IAP Versions section in order to install the Example Project.
  • Import the Example Project in Admin Essentials.

Testing

Cypress is generally used to test all Itential Example Projects. While Cypress is an opensource tool, at Itential we have internal libraries that have been built around Cypress to allow us to test with a deployed IAP.

When certifying our Example Projects for a release of IAP we run these tests against the particular version of IAP and create a release branch in GitLab. If you do not see the Example Project available in your version of IAP please contact Itential.

While Itential tests this Example Project and its capabilities, it is often the case the customer environments offer their own unique circumstances. Therefore, it is our recommendation that you deploy this Example Project into a development/testing environment in which you can test the Example Project.

Using this Workflow Project

Workflow Projects contain 1 or more workflows. Each of these workflows have different inputs and outputs.

Create Branch - GitLab - REST

Workflow to create a new branch for an existing repository in GitLab.

Capabilities include:

  • Create a branch in a GitLab repository.

Entry Point IAP Component

The primary IAP component to run Create Branch - GitLab - REST is listed below:

IAP Component Name IAP Component Type
Create Branch - GitLab - REST Workflow

Inputs

The following table lists the inputs for Create Branch - GitLab - REST:

Name Type Required Description Example Value
adapterId string yes Id of the GitLab adapter instance to use.
gitlab
branchName string yes Name of new branch to create.
new-feature
sourceBranchName string yes Name of branch to create the new branch from.
master
projectPath string yes Full path to the gitlab repository including subgroups. Can optionally use project id instead.
itentialopensource/adapters/devops-netops/adapter-gitlab

Outputs

The following table lists the outputs for Create Branch - GitLab - REST:

Name Type Description Example Value
createdBranch object Response from successful branch creation.
{
  "icode": "AD.201",
  "response": {
    "name": "my_branch",
    "commit": {
      "id": "fffb9e7b72d22929fb239ff56158",
      "short_id": "fffb9e7b",
      "created_at": "2024-01-25T22:03:03.000+00:00",
      "parent_ids": [
        "e3ca3a503703c35801e7416e654"
      ],
      "title": "update test",
      "message": "update test",
      "author_name": "Test User",
      "author_email": "test.user@itential.com",
      "authored_date": "2024-01-25T22:03:03.000+00:00",
      "committer_name": "Test User",
      "committer_email": "test.user@itential.com",
      "committed_date": "2024-01-25T22:03:03.000+00:00",
      "trailers": {},
      "extended_trailers": {},
      "web_url": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test/-/commit/fffb9e7b72d22929b1c24cd99ceffb239ff56158"
    },
    "merged": false,
    "protected": false,
    "developers_can_push": false,
    "developers_can_merge": false,
    "can_push": true,
    "default": false,
    "web_url": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test/-/tree/my_branch"
  }
}
gitlabError object Error response from branch creation failure.
{
  "icode": "AD.500",
  "IAPerror": {
    "origin": "gitlab-connectorRest-handleEndResponse",
    "displayString": "Error 404 received on request",
    "recommendation": "Verify the request is accurate via debug logs and postman",
    "code": 404,
    "raw_response": {
      "status": "success",
      "code": 404,
      "headers": {
        "date": "Fri, 26 Jan 2024 17:31:52 GMT",
        "content-type": "application/json",
        "content-length": 36,
        "connection": "close",
        "cache-control": "no-cache",
        "content-security-policy": "default-src 'none'",
        "vary": "Origin",
        "x-content-type-options": "nosniff",
        "x-frame-options": "SAMEORIGIN",
        "x-runtime": 0.074492,
        "strict-transport-security": "max-age=31536000",
        "referrer-policy": "strict-origin-when-cross-origin",
        "cf-cache-status": "DYNAMIC",
        "group": "cf-nel",
        "max_age": 604800
      },
      "nel": {
        "success_fraction": 0.01,
        "report_to": "cf-nel",
        "max_age": 604800
      }
    },
    "response": {
      "message": "404 Project Not Found"
    },
    "redirects": 0,
    "tripTime": "208ms",
    "reqHdr": {
      "Content-Type": "application/json",
      "Accept": "application/json",
      "Content-length": 161,
      "Private-Token": "****"
    }
  },
  "response": {
    "message": "404 Project Not Found"
  }
}

Query Output

No object to query upon success

Example Inputs and Outputs

Example 1

Input:

{
  "adapterId": "gitlab",
  "branchName": "my_branch",
  "sourceBranchName": "main",
  "projectPath": "itentialopensource/pre-built-automations/staging/pre-built-test/test_repo"
} 

Output:

{
  "createdBranch": {
    "icode": "AD.201",
    "response": {
      "name": "my_branch",
      "commit": {
        "id": "fffb9e7b72d22929fb239ff56158",
        "short_id": "fffb9e7b",
        "created_at": "2024-01-25T22:03:03.000+00:00",
        "parent_ids": [
          "e3ca3a503703c35801e7416e654"
        ],
        "title": "update test",
        "message": "update test",
        "author_name": "Test User",
        "author_email": "test.user@itential.com",
        "authored_date": "2024-01-25T22:03:03.000+00:00",
        "committer_name": "Test User",
        "committer_email": "test.user@itential.com",
        "committed_date": "2024-01-25T22:03:03.000+00:00",
        "trailers": {},
        "extended_trailers": {},
        "web_url": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test/-/commit/fffb9e7b72d22929b1c24cd99ceffb239ff56158"
      },
      "merged": false,
      "protected": false,
      "developers_can_push": false,
      "developers_can_merge": false,
      "can_push": true,
      "default": false,
      "web_url": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test/-/tree/my_branch"
    }
  }
} 

API Links

API Name API Documentation Link API Link Visibility
Branches API - GitLab https://docs.gitlab.com/ee/api/branches.html Public

Create Merge Request - GitLab - REST

Workflow that creates a new merge request for an existing branch in GitLab.

Capabilities include:

  • Create a new merge request in a GitLab repository.

Entry Point IAP Component

The primary IAP component to run Create Merge Request - GitLab - REST is listed below:

IAP Component Name IAP Component Type
Create Merge Request - GitLab - REST Workflow

Inputs

The following table lists the inputs for Create Merge Request - GitLab - REST:

Name Type Required Description Example Value
adapterId string yes Id of the GitLab adapter instance to use.
gitlab
sourceBranch string yes Name of branch to merge.
new-feature
targetBranch string yes Name of branch to merge into.
master
mergeRequestTitle string yes Title for merge request
New Feature for XYZ
projectPath string yes Full path to the gitlab repository including subgroups. Can optionally use project id instead.
itentialopensource/adapters/devops-netops/adapter-gitlab

Outputs

The following table lists the outputs for Create Merge Request - GitLab - REST:

Name Type Description Example Value
gitlabError object Error response from create merge request failure.
{
  "icode": "AD.500",
  "IAPerror": {
    "origin": "gitlab-connectorRest-handleEndResponse",
    "displayString": "Error 404 received on request",
    "recommendation": "Verify the request is accurate via debug logs and postman",
    "code": 404,
    "raw_response": {
      "status": "success",
      "code": 404,
      "headers": {
        "date": "Fri, 26 Jan 2024 17:31:52 GMT",
        "content-type": "application/json",
        "content-length": 36,
        "connection": "close",
        "cache-control": "no-cache",
        "content-security-policy": "default-src 'none'",
        "vary": "Origin",
        "x-content-type-options": "nosniff",
        "x-frame-options": "SAMEORIGIN",
        "x-runtime": 0.074492,
        "strict-transport-security": "max-age=31536000",
        "referrer-policy": "strict-origin-when-cross-origin",
        "cf-cache-status": "DYNAMIC",
        "group": "cf-nel",
        "max_age": 604800
      },
      "nel": {
        "success_fraction": 0.01,
        "report_to": "cf-nel",
        "max_age": 604800
      }
    },
    "response": {
      "message": "404 Project Not Found"
    },
    "redirects": 0,
    "tripTime": "208ms",
    "reqHdr": {
      "Content-Type": "application/json",
      "Accept": "application/json",
      "Content-length": 161,
      "Private-Token": "****"
    }
  },
  "response": {
    "message": "404 Project Not Found"
  }
}

Query Output

There are no query output examples for Create Merge Request - GitLab - REST.

Example Inputs and Outputs

Example 1

Input:

{
  "adapterId": "gitlab",
  "sourceBranch": "my_branch",
  "targetBranch": "main",
  "mergeRequestTitle": "merge into main",
  "projectPath": "itentialopensource/pre-built-automations/staging/pre-built-test/test_repo"
} 

API Links

API Name API Documentation Link API Link Visibility
Merge Requests API - GitLab https://docs.gitlab.com/ee/api/merge_requests.html Public

Create Project - GitLab - REST

This workflow creates a new GitLab repository with or without using a template.

Capabilities include:

  • Create a new GitLab repository.

Entry Point IAP Component

The primary IAP component to run Create Project - GitLab - REST is listed below:

IAP Component Name IAP Component Type
Create Project - GitLab - REST Workflow

Inputs

The following table lists the inputs for Create Project - GitLab - REST:

Name Type Required Description Example Value
group_id string yes Group ID for group to create the new project within
36426787
new_project_name string yes Name for the new project.
my_repo
adapterId string yes Id of the GitLab adapter instance to use.
gitlab
template_name string yes Name for the template to create the project from. If not using a template provide an empty string ("")
template_a
project_description string yes Description for the repository
Project for use case x.
template_group_id string yes Group Id for project template. If not using a template provide an empty string ("")
123532

Outputs

The following table lists the outputs for Create Project - GitLab - REST:

Name Type Description Example Value
ReturnStatus object Return status from gitlab for project creation
{
  "status": "SUCCESS",
  "message": "Project Created Successfully",
  "errors": [],
  "response": {
    "create_project": {
      "icode": "AD.201",
      "response": {
        "pathParam": "test",
        "tagList": [],
        "createdAt": "2024-01-25T20:28:55.636Z",
        "id": 54252513,
        "description": "Migration test",
        "name": "test",
        "name_with_namespace": "Itential Open Source / pre-built automations / staging / Pre-Built Test / test",
        "path_with_namespace": "itentialopensource/pre-built-automations/staging/pre-built-test/test",
        "default_branch": "main",
        "topics": [],
        "ssh_url_to_repo": "git@gitlab.com:itentialopensource/pre-built-automations/staging/pre-built-test/test.git",
        "http_url_to_repo": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test.git",
        "web_url": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test",
        "readme_url": null,
        "forks_count": 0,
        "avatar_url": null,
        "star_count": 0,
        "last_activity_at": "2024-01-25T20:28:55.636Z",
        "namespace": {
          "id": 67722271,
          "name": "Pre-Built Test",
          "path": "pre-built-test",
          "kind": "group",
          "full_path": "itentialopensource/pre-built-automations/staging/pre-built-test",
          "parent_id": 6535607,
          "avatar_url": null,
          "web_url": "https://gitlab.com/groups/itentialopensource/pre-built-automations/staging/pre-built-test"
        },
        "container_registry_image_prefix": "registry.gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test",
        "_links": {
          "self": "https://gitlab.com/api/v4/projects/54252513",
          "issues": "https://gitlab.com/api/v4/projects/54252513/issues",
          "merge_requests": "https://gitlab.com/api/v4/projects/54252513/merge_requests",
          "repo_branches": "https://gitlab.com/api/v4/projects/54252513/repository/branches",
          "labels": "https://gitlab.com/api/v4/projects/54252513/labels",
          "events": "https://gitlab.com/api/v4/projects/54252513/events",
          "members": "https://gitlab.com/api/v4/projects/54252513/members",
          "cluster_agents": "https://gitlab.com/api/v4/projects/54252513/cluster_agents"
        },
        "code_suggestions": true,
        "packages_enabled": true,
        "empty_repo": true,
        "archived": false,
        "visibility": "private",
        "resolve_outdated_diff_discussions": false,
        "container_expiration_policy": {
          "cadence": "1d",
          "enabled": false,
          "keep_n": 10,
          "older_than": "90d",
          "name_regex": ".*",
          "name_regex_keep": null,
          "next_run_at": "2024-01-26T20:28:55.672Z"
        },
        "issues_enabled": true,
        "merge_requests_enabled": true,
        "wiki_enabled": true,
        "jobs_enabled": true,
        "snippets_enabled": true,
        "container_registry_enabled": true,
        "service_desk_enabled": true,
        "service_desk_address": "contact-project+itentialopensource-pre-built-automations-staging-pre-built-test-54252513-issue-@incoming.gitlab.com",
        "can_create_merge_request_in": true,
        "issues_access_level": "enabled",
        "repository_access_level": "enabled",
        "merge_requests_access_level": "enabled",
        "forking_access_level": "enabled",
        "wiki_access_level": "enabled",
        "builds_access_level": "enabled",
        "snippets_access_level": "enabled",
        "pages_access_level": "private",
        "analytics_access_level": "enabled",
        "container_registry_access_level": "enabled",
        "security_and_compliance_access_level": "private",
        "releases_access_level": "enabled",
        "environments_access_level": "enabled",
        "feature_flags_access_level": "enabled",
        "infrastructure_access_level": "enabled",
        "monitor_access_level": "enabled",
        "model_experiments_access_level": "enabled",
        "model_registry_access_level": "enabled",
        "emails_disabled": false,
        "emails_enabled": true,
        "shared_runners_enabled": true,
        "lfs_enabled": true,
        "creator_id": 9009869,
        "import_url": null,
        "import_type": null,
        "import_status": "none",
        "import_error": null,
        "open_issues_count": 0,
        "description_html": "

Migration test

", "updated_at": "2024-01-25T20:28:55.636Z", "ci_default_git_depth": 20, "ci_forward_deployment_enabled": true, "ci_forward_deployment_rollback_allowed": true, "ci_job_token_scope_enabled": false, "ci_separated_caches": true, "ci_allow_fork_pipelines_to_run_in_parent_project": true, "build_git_strategy": "fetch", "keep_latest_artifact": true, "restrict_user_defined_variables": false, "runners_token": "GR1348941bZnCnAomMJmVT3RzWypG", "runner_token_expiration_interval": null, "group_runners_enabled": true, "auto_cancel_pending_pipelines": "enabled", "build_timeout": 3600, "auto_devops_enabled": false, "auto_devops_deploy_strategy": "continuous", "ci_config_path": "", "public_jobs": true, "shared_with_groups": [], "only_allow_merge_if_pipeline_succeeds": false, "allow_merge_on_skipped_pipeline": null, "request_access_enabled": true, "only_allow_merge_if_all_discussions_are_resolved": false, "remove_source_branch_after_merge": true, "printing_merge_request_link_enabled": true, "merge_method": "merge", "squash_option": "default_off", "enforce_auth_checks_on_uploads": true, "suggestion_commit_message": null, "merge_commit_template": null, "squash_commit_template": null, "issue_branch_template": null, "autoclose_referenced_issues": true, "approvals_before_merge": 0, "mirror": false, "external_authorization_classification_label": "", "marked_for_deletion_at": null, "marked_for_deletion_on": null, "requirements_enabled": true, "requirements_access_level": "enabled", "security_and_compliance_enabled": true, "compliance_frameworks": [], "issues_template": null, "merge_requests_template": null, "ci_restrict_pipeline_cancellation_role": "developer", "merge_pipelines_enabled": false, "merge_trains_enabled": false, "merge_trains_skip_train_allowed": false, "only_allow_merge_if_all_status_checks_passed": false, "allow_pipeline_trigger_approve_deployment": false, "prevent_merge_without_jira_issue": false } } }, "group_id": 67722271, "project_id": 54252513 }

Query Output

There are no query output examples for Create Project - GitLab - REST.

Example Inputs and Outputs

Example 1

Input:

{
  "group_id": "67722271",
  "new_project_name": "project_test",
  "adapterId": "gitlab",
  "template_name": "",
  "project_description": "My test",
  "template_group_id": "",
  "verbose": true
} 

Output:

{
  "ReturnStatus": {
    "status": "SUCCESS",
    "message": "Project Created Successfully",
    "errors": [],
    "response": {
      "create_project": {
        "icode": "AD.201",
        "response": {
          "pathParam": "test",
          "tagList": [],
          "createdAt": "2024-01-25T20:28:55.636Z",
          "id": 54252513,
          "description": "Migration test",
          "name": "test",
          "name_with_namespace": "Itential Open Source / pre-built automations / staging / Pre-Built Test / test",
          "path_with_namespace": "itentialopensource/pre-built-automations/staging/pre-built-test/test",
          "default_branch": "main",
          "topics": [],
          "ssh_url_to_repo": "git@gitlab.com:itentialopensource/pre-built-automations/staging/pre-built-test/test.git",
          "http_url_to_repo": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test.git",
          "web_url": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test",
          "readme_url": null,
          "forks_count": 0,
          "avatar_url": null,
          "star_count": 0,
          "last_activity_at": "2024-01-25T20:28:55.636Z",
          "namespace": {
            "id": 67722271,
            "name": "Pre-Built Test",
            "path": "pre-built-test",
            "kind": "group",
            "full_path": "itentialopensource/pre-built-automations/staging/pre-built-test",
            "parent_id": 6535607,
            "avatar_url": null,
            "web_url": "https://gitlab.com/groups/itentialopensource/pre-built-automations/staging/pre-built-test"
          },
          "container_registry_image_prefix": "registry.gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test",
          "_links": {
            "self": "https://gitlab.com/api/v4/projects/54252513",
            "issues": "https://gitlab.com/api/v4/projects/54252513/issues",
            "merge_requests": "https://gitlab.com/api/v4/projects/54252513/merge_requests",
            "repo_branches": "https://gitlab.com/api/v4/projects/54252513/repository/branches",
            "labels": "https://gitlab.com/api/v4/projects/54252513/labels",
            "events": "https://gitlab.com/api/v4/projects/54252513/events",
            "members": "https://gitlab.com/api/v4/projects/54252513/members",
            "cluster_agents": "https://gitlab.com/api/v4/projects/54252513/cluster_agents"
          },
          "code_suggestions": true,
          "packages_enabled": true,
          "empty_repo": true,
          "archived": false,
          "visibility": "private",
          "resolve_outdated_diff_discussions": false,
          "container_expiration_policy": {
            "cadence": "1d",
            "enabled": false,
            "keep_n": 10,
            "older_than": "90d",
            "name_regex": ".*",
            "name_regex_keep": null,
            "next_run_at": "2024-01-26T20:28:55.672Z"
          },
          "issues_enabled": true,
          "merge_requests_enabled": true,
          "wiki_enabled": true,
          "jobs_enabled": true,
          "snippets_enabled": true,
          "container_registry_enabled": true,
          "service_desk_enabled": true,
          "service_desk_address": "contact-project+itentialopensource-pre-built-automations-staging-pre-built-test-54252513-issue-@incoming.gitlab.com",
          "can_create_merge_request_in": true,
          "issues_access_level": "enabled",
          "repository_access_level": "enabled",
          "merge_requests_access_level": "enabled",
          "forking_access_level": "enabled",
          "wiki_access_level": "enabled",
          "builds_access_level": "enabled",
          "snippets_access_level": "enabled",
          "pages_access_level": "private",
          "analytics_access_level": "enabled",
          "container_registry_access_level": "enabled",
          "security_and_compliance_access_level": "private",
          "releases_access_level": "enabled",
          "environments_access_level": "enabled",
          "feature_flags_access_level": "enabled",
          "infrastructure_access_level": "enabled",
          "monitor_access_level": "enabled",
          "model_experiments_access_level": "enabled",
          "model_registry_access_level": "enabled",
          "emails_disabled": false,
          "emails_enabled": true,
          "shared_runners_enabled": true,
          "lfs_enabled": true,
          "creator_id": 9009869,
          "import_url": null,
          "import_type": null,
          "import_status": "none",
          "import_error": null,
          "open_issues_count": 0,
          "description_html": "

Migration test

", "updated_at": "2024-01-25T20:28:55.636Z", "ci_default_git_depth": 20, "ci_forward_deployment_enabled": true, "ci_forward_deployment_rollback_allowed": true, "ci_job_token_scope_enabled": false, "ci_separated_caches": true, "ci_allow_fork_pipelines_to_run_in_parent_project": true, "build_git_strategy": "fetch", "keep_latest_artifact": true, "restrict_user_defined_variables": false, "runners_token": "GR1348941bZnCnAomMJmVT3RzWypG", "runner_token_expiration_interval": null, "group_runners_enabled": true, "auto_cancel_pending_pipelines": "enabled", "build_timeout": 3600, "auto_devops_enabled": false, "auto_devops_deploy_strategy": "continuous", "ci_config_path": "", "public_jobs": true, "shared_with_groups": [], "only_allow_merge_if_pipeline_succeeds": false, "allow_merge_on_skipped_pipeline": null, "request_access_enabled": true, "only_allow_merge_if_all_discussions_are_resolved": false, "remove_source_branch_after_merge": true, "printing_merge_request_link_enabled": true, "merge_method": "merge", "squash_option": "default_off", "enforce_auth_checks_on_uploads": true, "suggestion_commit_message": null, "merge_commit_template": null, "squash_commit_template": null, "issue_branch_template": null, "autoclose_referenced_issues": true, "approvals_before_merge": 0, "mirror": false, "external_authorization_classification_label": "", "marked_for_deletion_at": null, "marked_for_deletion_on": null, "requirements_enabled": true, "requirements_access_level": "enabled", "security_and_compliance_enabled": true, "compliance_frameworks": [], "issues_template": null, "merge_requests_template": null, "ci_restrict_pipeline_cancellation_role": "developer", "merge_pipelines_enabled": false, "merge_trains_enabled": false, "merge_trains_skip_train_allowed": false, "only_allow_merge_if_all_status_checks_passed": false, "allow_pipeline_trigger_approve_deployment": false, "prevent_merge_without_jira_issue": false } } }, "group_id": 67722271, "project_id": 54252513 } }

API Links

API Name API Documentation Link API Link Visibility
Projects API - GitLab https://docs.gitlab.com/ee/api/projects.html Public

Get Branch - GitLab - REST

Workflow to get a branch for an existing repository in GitLab.

Capabilities include:

  • Get branch details from a GitLab repository.

Entry Point IAP Component

The primary IAP component to run Get Branch - GitLab - REST is listed below:

IAP Component Name IAP Component Type
Get Branch - GitLab - REST Workflow

Inputs

The following table lists the inputs for Get Branch - GitLab - REST:

Name Type Required Description Example Value
adapterId string yes Id of the GitLab adapter instance to use.
gitlab
projectPath string yes Full path to the gitlab repository including subgroups. Can optionally use project id instead.
itentialopensource/adapters/devops-netops/adapter-gitlab
branchName string yes Name of branch to get
master

Outputs

The following table lists the outputs for Get Branch - GitLab - REST:

Name Type Description Example Value
gitLabBranch object Gitlab response for get branch call.
{
  "icode": "AD.200",
  "response": {
    "name": "my_branch",
    "commit": {
      "id": "11d41003f393d3118336966b04c5612f9515bdcd",
      "short_id": "11d41003",
      "created_at": "2024-01-25T22:05:42.000+00:00",
      "parent_ids": [
        "fffb9e7b72d22929b1c24cd99ceffb239ff56158"
      ],
      "title": "here's a new file",
      "message": "here's a new file",
      "author_name": "Test User",
      "author_email": "test.user@itential.com",
      "authored_date": "2024-01-25T22:05:42.000+00:00",
      "committer_name": "Test User",
      "committer_email": "test.user@itential.com",
      "committed_date": "2024-01-25T22:05:42.000+00:00",
      "trailers": {},
      "extended_trailers": {},
      "web_url": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test/-/commit/11d41003f393d3118336966b04c5612f9515bdcd"
    },
    "merged": false,
    "protected": false,
    "developers_can_push": false,
    "developers_can_merge": false,
    "can_push": true,
    "default": false,
    "web_url": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test/-/tree/my_branch"
  }
}
gitlabError object Error response from branch get failure.
{
  "icode": "AD.500",
  "IAPerror": {
    "origin": "gitlab-connectorRest-handleEndResponse",
    "displayString": "Error 404 received on request",
    "recommendation": "Verify the request is accurate via debug logs and postman",
    "code": 404,
    "raw_response": {
      "status": "success",
      "code": 404,
      "headers": {
        "date": "Fri, 26 Jan 2024 17:31:52 GMT",
        "content-type": "application/json",
        "content-length": 36,
        "connection": "close",
        "cache-control": "no-cache",
        "content-security-policy": "default-src 'none'",
        "vary": "Origin",
        "x-content-type-options": "nosniff",
        "x-frame-options": "SAMEORIGIN",
        "x-runtime": 0.074492,
        "strict-transport-security": "max-age=31536000",
        "referrer-policy": "strict-origin-when-cross-origin",
        "cf-cache-status": "DYNAMIC",
        "group": "cf-nel",
        "max_age": 604800
      },
      "nel": {
        "success_fraction": 0.01,
        "report_to": "cf-nel",
        "max_age": 604800
      }
    },
    "response": {
      "message": "404 Branch Not Found"
    },
    "redirects": 0,
    "tripTime": "208ms",
    "reqHdr": {
      "Content-Type": "application/json",
      "Accept": "application/json",
      "Content-length": 161,
      "Private-Token": "****"
    }
  },
  "metrics": {
    "code": 404,
    "timeouts": 0,
    "redirects": 0,
    "retries": 0,
    "tripTime": 208,
    "isThrottling": false,
    "capabilityTime": "577ms"
  },
  "response": {
    "message": "404 Branch Not Found"
  }
}

Query Output

There are no query output examples for Get Branch - GitLab - REST.

Example Inputs and Outputs

Example 1

Input:

{
  "projectPath": "itentialopensource/pre-built-automations/staging/pre-built-test/test",
  "adapterId": "gitlab",
  "branchName": "my_branch"
} 

Output:

{
  "gitLabBranch": {
    "icode": "AD.200",
    "response": {
      "name": "my_branch",
      "commit": {
        "id": "11d41003f393d3118336966b04c5612f9515bdcd",
        "short_id": "11d41003",
        "created_at": "2024-01-25T22:05:42.000+00:00",
        "parent_ids": [
          "fffb9e7b72d22929b1c24cd99ceffb239ff56158"
        ],
        "title": "here's a new file",
        "message": "here's a new file",
        "author_name": "Test User",
        "author_email": "test.user@itential.com",
        "authored_date": "2024-01-25T22:05:42.000+00:00",
        "committer_name": "Test User",
        "committer_email": "test.user@itential.com",
        "committed_date": "2024-01-25T22:05:42.000+00:00",
        "trailers": {},
        "extended_trailers": {},
        "web_url": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test/-/commit/11d41003f393d3118336966b04c5612f9515bdcd"
      },
      "merged": false,
      "protected": false,
      "developers_can_push": false,
      "developers_can_merge": false,
      "can_push": true,
      "default": false,
      "web_url": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test/-/tree/my_branch"
    }
  }
} 

API Links

API Name API Documentation Link API Link Visibility
Branches API - GitLab https://docs.gitlab.com/ee/api/branches.html Public

Get Diff for Merge - GitLab - REST

Workflow that gets a diff for a merge request in GitLab.

Capabilities include:

  • Get diff between a source and target branch in a GitLab merge request.

Entry Point IAP Component

The primary IAP component to run Get Diff for Merge - GitLab - REST is listed below:

IAP Component Name IAP Component Type
Get Diff for Merge - GitLab - REST Workflow

Inputs

The following table lists the inputs for Get Diff for Merge - GitLab - REST:

Name Type Required Description Example Value
projectId string yes Id of the GitLab project
36426787
mergeRequestIid string yes Instance id of merge request
2
adapterId string yes Id of the GitLab adapter instance to use.
gitlab
verbose boolean yes Whether or not to use zero touch mode (manual tasks)
true

Outputs

The following table lists the outputs for Get Diff for Merge - GitLab - REST:

Name Type Description Example Value
ReturnStatus object Return status from gitlab for diff
{
  "status": "SUCCESS",
  "message": "Diff found",
  "errors": [],
  "response": {
    "get a project": {
      "icode": "AD.200",
      "response": {
        "pathParam": "test",
        "tagList": [],
        "createdAt": "2024-01-25T20:28:55.636Z",
        "id": 54252513,
        "description": "Migration test",
        "name": "test",
        "name_with_namespace": "Itential Open Source / pre-built automations / staging / Pre-Built Test / test",
        "path_with_namespace": "itentialopensource/pre-built-automations/staging/pre-built-test/test",
        "default_branch": "main",
        "topics": [],
        "ssh_url_to_repo": "git@gitlab.com:itentialopensource/pre-built-automations/staging/pre-built-test/test.git",
        "http_url_to_repo": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test.git",
        "web_url": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test",
        "readme_url": null,
        "forks_count": 0,
        "avatar_url": null,
        "star_count": 0,
        "last_activity_at": "2024-01-25T21:57:57.890Z",
        "namespace": {
          "id": 67722271,
          "name": "Pre-Built Test",
          "path": "pre-built-test",
          "kind": "group",
          "full_path": "itentialopensource/pre-built-automations/staging/pre-built-test",
          "parent_id": 6535607,
          "avatar_url": null,
          "web_url": "https://gitlab.com/groups/itentialopensource/pre-built-automations/staging/pre-built-test"
        },
        "container_registry_image_prefix": "registry.gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test",
        "_links": {
          "self": "https://gitlab.com/api/v4/projects/54252513",
          "issues": "https://gitlab.com/api/v4/projects/54252513/issues",
          "merge_requests": "https://gitlab.com/api/v4/projects/54252513/merge_requests",
          "repo_branches": "https://gitlab.com/api/v4/projects/54252513/repository/branches",
          "labels": "https://gitlab.com/api/v4/projects/54252513/labels",
          "events": "https://gitlab.com/api/v4/projects/54252513/events",
          "members": "https://gitlab.com/api/v4/projects/54252513/members",
          "cluster_agents": "https://gitlab.com/api/v4/projects/54252513/cluster_agents"
        },
        "code_suggestions": true,
        "packages_enabled": true,
        "empty_repo": false,
        "archived": false,
        "visibility": "private",
        "resolve_outdated_diff_discussions": false,
        "container_expiration_policy": {
          "cadence": "1d",
          "enabled": false,
          "keep_n": 10,
          "older_than": "90d",
          "name_regex": ".*",
          "name_regex_keep": null,
          "next_run_at": "2024-01-26T20:28:55.672Z"
        },
        "permissions": {
          "project_access": null,
          "group_access": {
            "access_level": 40,
            "notification_level": 3
          }
        }
      }
    },
    "get diff for a specific committ": {
      "icode": "AD.200",
      "response": [
        {
          "diff": "@@ -0,0 +1 @@\n+hello world\n\\ No newline at end of file\n",
          "new_path": "newfile.txt",
          "old_path": "newfile.txt",
          "a_mode": "0",
          "b_mode": "100644",
          "new_file": true,
          "renamed_file": false,
          "deleted_file": false,
          "generated_file": null
        }
      ]
    }
  },
  "mergeRequestId": "1"
}
result array Result containing the diff for the MR
[
  [
    {
      "diff": "@@ -0,0 +1 @@\n+hello world\n\\ No newline at end of file\n",
      "new_path": "newfile.txt",
      "old_path": "newfile.txt",
      "a_mode": "0",
      "b_mode": "100644",
      "new_file": true,
      "renamed_file": false,
      "deleted_file": false,
      "generated_file": null
    }
  ]
]

Query Output

There are no query output examples for Get Diff for Merge - GitLab - REST.

Example Inputs and Outputs

Example 1

Input:

{
  "projectId": "54252513",
  "mergeRequestIid": "1",
  "adapterId": "gitlab",
  "verbose": true
} 

Output:

{
  "ReturnStatus": {
    "status": "SUCCESS",
    "message": "Diff found",
    "errors": [],
    "response": {
      "get a project": {
        "icode": "AD.200",
        "response": {
          "pathParam": "test",
          "tagList": [],
          "createdAt": "2024-01-25T20:28:55.636Z",
          "id": 54252513,
          "description": "Migration test",
          "name": "test",
          "name_with_namespace": "Itential Open Source / pre-built automations / staging / Pre-Built Test / test",
          "path_with_namespace": "itentialopensource/pre-built-automations/staging/pre-built-test/test",
          "default_branch": "main",
          "topics": [],
          "ssh_url_to_repo": "git@gitlab.com:itentialopensource/pre-built-automations/staging/pre-built-test/test.git",
          "http_url_to_repo": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test.git",
          "web_url": "https://gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test",
          "readme_url": null,
          "forks_count": 0,
          "avatar_url": null,
          "star_count": 0,
          "last_activity_at": "2024-01-25T21:57:57.890Z",
          "namespace": {
            "id": 67722271,
            "name": "Pre-Built Test",
            "path": "pre-built-test",
            "kind": "group",
            "full_path": "itentialopensource/pre-built-automations/staging/pre-built-test",
            "parent_id": 6535607,
            "avatar_url": null,
            "web_url": "https://gitlab.com/groups/itentialopensource/pre-built-automations/staging/pre-built-test"
          },
          "container_registry_image_prefix": "registry.gitlab.com/itentialopensource/pre-built-automations/staging/pre-built-test/test",
          "_links": {
            "self": "https://gitlab.com/api/v4/projects/54252513",
            "issues": "https://gitlab.com/api/v4/projects/54252513/issues",
            "merge_requests": "https://gitlab.com/api/v4/projects/54252513/merge_requests",
            "repo_branches": "https://gitlab.com/api/v4/projects/54252513/repository/branches",
            "labels": "https://gitlab.com/api/v4/projects/54252513/labels",
            "events": "https://gitlab.com/api/v4/projects/54252513/events",
            "members": "https://gitlab.com/api/v4/projects/54252513/members",
            "cluster_agents": "https://gitlab.com/api/v4/projects/54252513/cluster_agents"
          },
          "code_suggestions": true,
          "packages_enabled": true,
          "empty_repo": false,
          "archived": false,
          "visibility": "private",
          "resolve_outdated_diff_discussions": false,
          "container_expiration_policy": {
            "cadence": "1d",
            "enabled": false,
            "keep_n": 10,
            "older_than": "90d",
            "name_regex": ".*",
            "name_regex_keep": null,
            "next_run_at": "2024-01-26T20:28:55.672Z"
          },
          "permissions": {
            "project_access": null,
            "group_access": {
              "access_level": 40,
              "notification_level": 3
            }
          }
        }
      },
      "get diff for a specific committ": {
        "icode": "AD.200",
        "response": [
          {
            "diff": "@@ -0,0 +1 @@\n+hello world\n\\ No newline at end of file\n",
            "new_path": "newfile.txt",
            "old_path": "newfile.txt",
            "a_mode": "0",
            "b_mode": "100644",
            "new_file": true,
            "renamed_file": false,
            "deleted_file": false,
            "generated_file": null
          }
        ]
      }
    },
    "mergeRequestId": "1"
  },
  "result": [
    [
      {
        "diff": "@@ -0,0 +1 @@\n+hello world\n\\ No newline at end of file\n",
        "new_path": "newfile.txt",
        "old_path": "newfile.txt",
        "a_mode": "0",
        "b_mode": "100644",
        "new_file": true,
        "renamed_file": false,
        "deleted_file": false,
        "generated_file": null
      }
    ]
  ],
  "current_item": {}
} 

API Links

API Name API Documentation Link API Link Visibility
Merge Requests API - GitLab https://docs.gitlab.com/ee/api/merge_requests.html Public

Get File - GitLab - REST

Workflow that get a file from a repository in GitLab.

Capabilities include:

  • Get a file in a GitLab repository.

Entry Point IAP Component

The primary IAP component to run Get File - GitLab - REST is listed below:

IAP Component Name IAP Component Type
Get File - GitLab - REST Workflow

Inputs

The following table lists the inputs for Get File - GitLab - REST:

Name Type Required Description Example Value
filePath string yes Path to file not including file name
documentation/data
projectPath string yes Full path to the gitlab repository including subgroups. Can optionally use project id instead.
itentialopensource/adapters/devops-netops/adapter-gitlab
adapterId string yes Id of the GitLab adapter instance to use.
gitlab
fileName string yes Name of the file to get
test.txt

Outputs

The following table lists the outputs for Get File - GitLab - REST:

Name Type Description Example Value
result object File contents
{
  "response": "Hello world!",
  "result": "success",
  "code": 200
}

Query Output

There are no query output examples for Get File - GitLab - REST.

Example Inputs and Outputs

Example 1

Input:

{
  "filePath": "report",
  "adapterId": "gitlab",
  "projectPath": "itentialopensource/adapters/cloud/adapter-aws_ec2",
  "fileName": "adapterInfo.json"
} 

Output:

{  
"result": {
    "response": {
      "version": "0.7.3",
      "configLines": 64140,
      "scriptLines": 1783,
      "codeLines": 49891,
      "testLines": 26311,
      "testCases": 1400,
      "totalCodeLines": 77985,
      "wfTasks": 854
    },
    "result": "success",
    "code": 200
  }
} 

API Links

API Name API Documentation Link API Link Visibility
Repository Files API - GitLab https://docs.gitlab.com/ee/api/repository_files.html Public

Push Commit to Branch - GitLab - REST

Push a commit to a branch in Gitlab

Capabilities include:

  • Make commit to an existing branch in a GitLab repository.

Entry Point IAP Component

The primary IAP component to run Push Commit to Branch - GitLab - REST is listed below:

IAP Component Name IAP Component Type
Push Commit to Branch - GitLab - REST Workflow

Inputs

The following table lists the inputs for Push Commit to Branch - GitLab - REST:

Name Type Required Description Example Value
filePath string yes Path to file including file name
documentation/data.txt
branchName string yes Name of the branch to commit to
new-feature
adapterId string yes Id of the GitLab adapter instance to use.
gitlab
projectPath string yes Full path to the gitlab repository including subgroups. Can optionally use project id instead.
itentialopensource/adapters/devops-netops/adapter-gitlab
commitMessage string yes Message to include with the commit
Update to file x
fileContent string yes Content for file to add or update
hello world!

Outputs

The following table lists the outputs for Push Commit to Branch - GitLab - REST:

Name Type Description Example Value
gitlabError object Error response from Gitlab failure.
{
  "icode": "AD.500",
  "IAPerror": {
    "origin": "gitlab-connectorRest-handleEndResponse",
    "displayString": "Error 404 received on request",
    "recommendation": "Verify the request is accurate via debug logs and postman",
    "code": 404,
    "raw_response": {
      "status": "success",
      "code": 404,
      "headers": {
        "date": "Fri, 26 Jan 2024 17:31:52 GMT",
        "content-type": "application/json",
        "content-length": 36,
        "connection": "close",
        "cache-control": "no-cache",
        "content-security-policy": "default-src 'none'",
        "vary": "Origin",
        "x-content-type-options": "nosniff",
        "x-frame-options": "SAMEORIGIN",
        "x-runtime": 0.074492,
        "strict-transport-security": "max-age=31536000",
        "referrer-policy": "strict-origin-when-cross-origin",
        "cf-cache-status": "DYNAMIC",
        "group": "cf-nel",
        "max_age": 604800
      },
      "nel": {
        "success_fraction": 0.01,
        "report_to": "cf-nel",
        "max_age": 604800
      }
    },
    "response": {
      "message": "404 Project Not Found"
    },
    "redirects": 0,
    "tripTime": "208ms",
    "reqHdr": {
      "Content-Type": "application/json",
      "Accept": "application/json",
      "Content-length": 161,
      "Private-Token": "****"
    }
  },
  "response": {
    "message": "404 Project Not Found"
  }
}

Query Output

There are no query output examples for Push Commit to Branch - GitLab - REST.

Example Inputs and Outputs

Example 1

Input:

{
  "filePath": "newfile.txt",
  "branchName": "my_branch",
  "adapterId": "gitlab",
  "projectPath": "itentialopensource/pre-built-automations/staging/pre-built-test/my_test",
  "commitMessage": "new file",
  "fileContent": "hello world"
} 

API Links

API Name API Documentation Link API Link Visibility
Commits API - GitLab https://docs.gitlab.com/ee/api/commits.html Public

Update Project Variables - GitLab - REST

Workflow to update CI/CD variables in GitLab

Capabilities include:

  • Update CI/CD variables in GitLab

Entry Point IAP Component

The primary IAP component to run Update Project Variables - GitLab - REST is listed below:

IAP Component Name IAP Component Type
Update Project Variables - GitLab - REST Workflow

Inputs

The following table lists the inputs for Update Project Variables - GitLab - REST:

Name Type Required Description Example Value
projectPath string yes Full path to the gitlab repository including subgroups. Can optionally use project id instead.
itentialopensource/adapters/devops-netops/adapter-gitlab
adapterId string yes Id of the GitLab adapter instance to use.
gitlab
variablesArray array yes Array of variables to update in repository.
[
  {
    "variable_type": "env_var",
    "key": "test",
    "value": "updated value",
    "protected": true,
    "masked": false,
    "raw": false,
    "environment_scope": "*",
    "description": "null"
  }
]

Outputs

The following table lists the outputs for Update Project Variables - GitLab - REST:

Name Type Description Example Value
gitlabError object Error response from update variables failure
{
  "icode": "AD.500",
  "IAPerror": {
    "origin": "gitlab-connectorRest-handleEndResponse",
    "displayString": "Error 404 received on request",
    "recommendation": "Verify the request is accurate via debug logs and postman",
    "code": 404,
    "raw_response": {
      "status": "success",
      "code": 404,
      "response": {
        "message": "404 Variable Not Found"
      },
      "redirects": 0,
      "tripTime": "208ms",
      "reqHdr": {
        "Content-Type": "application/json",
        "Accept": "application/json",
        "Content-length": 161,
        "Private-Token": "****"
      }
    }
  },
  "response": {
    "message": "404 Variable Not Found"
  }
}

Query Output

There are no query output examples for Update Project Variables - GitLab - REST.

Example Inputs and Outputs

Example 1

Input:

{
  "projectPath": "itentialopensource/pre-built-automations/staging/pre-built-test/my_test",
  "adapterId": "gitlab",
  "variablesArray": [
    {
      "variable_type": "env_var",
      "key": "test_var",
      "value": "updated value",
      "protected": true,
      "masked": false,
      "raw": false,
      "environment_scope": "*",
      "description": "null"
    }
  ]
} 

API Links

API Name API Documentation Link API Link Visibility
Instance-level CI/CD variables API https://docs.gitlab.com/ee/api/instance_level_ci_variables.html Public

Additional Information

Support

Please use your Itential Customer Success account if you need support when using this Workflow Project.