CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-release-it

Generic CLI tool to automate versioning and package publishing-related tasks.

Pending
Overview
Eval results
Files

gitlab-integration.mddocs/

GitLab Integration

The GitLab plugin provides comprehensive GitLab integration including release creation, asset uploads, and repository operations. It supports authentication, release notes generation, and asset management for both GitLab.com and self-hosted GitLab instances.

Capabilities

GitLab Plugin Class

Main GitLab integration plugin for releases and repository operations.

/**
 * GitLab integration plugin for releases and repository operations
 * Handles GitLab releases, asset uploads, and repository integration
 */
class GitLab extends Plugin {
  /** Initialize GitLab plugin with authentication and repository validation */
  init(): Promise<void>;
  
  /** Authentication and validation */
  isAuthenticated(): Promise<boolean>;
  isCollaborator(): Promise<boolean>;
  
  /** Get latest version from GitLab releases */
  getLatestVersion(): Promise<string>;
  
  /** Get changelog from GitLab commits and merge requests */
  getChangelog(): Promise<string>;
  
  /** Pre-release hook for milestone validation */
  beforeRelease(): Promise<void>;
  
  /**
   * Create GitLab release
   * @returns Promise resolving to boolean indicating success
   */
  release(): Promise<boolean>;
  
  /** Log release URL after successful release */
  afterRelease(): void;
  
  /** Release management */
  createRelease(): Promise<boolean>;
  checkReleaseMilestones(): Promise<void>;
  getReleaseMilestones(): string[];
  
  /** Asset management */
  uploadAsset(filePath: string): Promise<any>;
  uploadAssets(): Promise<void>;
  
  /** Repository information */
  getWebUrl(): string;
  
  /** API utilities */
  request(endpoint: string, options?: any): Promise<any>;
}

Release Operations

Methods for creating and managing GitLab releases.

/**
 * Create GitLab release with notes and assets
 * @param options - Release creation options
 * @returns Promise resolving to GitLab release object
 */
createRelease(options: CreateReleaseOptions): Promise<GitLabRelease>;

/**
 * Upload assets to GitLab package registry or generic packages
 * @param assets - Array of asset file paths or glob patterns
 * @returns Promise that resolves when all assets are uploaded
 */
uploadAssets(assets: string[]): Promise<void>;

/**
 * Get GitLab release by tag name
 * @param tag - Git tag name
 * @returns Promise resolving to release object or null if not found
 */
getReleaseByTag(tag: string): Promise<GitLabRelease | null>;

/**
 * Update existing GitLab release
 * @param releaseId - GitLab release ID
 * @param options - Update options
 * @returns Promise resolving to updated release object
 */
updateRelease(releaseId: number, options: UpdateReleaseOptions): Promise<GitLabRelease>;

interface CreateReleaseOptions {
  /** Release tag name */
  tag_name: string;
  /** Release name/title */
  name?: string;
  /** Release description/body */
  description?: string;
  /** Commit SHA or branch for release */
  ref?: string;
  /** Release milestones */
  milestones?: string[];
  /** Released date */
  released_at?: string;
}

interface UpdateReleaseOptions {
  /** Updated release name */
  name?: string;
  /** Updated release description */
  description?: string;
  /** Updated milestones */
  milestones?: string[];
}

interface GitLabRelease {
  /** Release tag name */
  tag_name: string;
  /** Release name */
  name: string;
  /** Release description */
  description: string;
  /** Release date */
  released_at: string;
  /** Release links */
  _links: {
    /** Web URL for the release */
    self: string;
  };
  /** Associated milestones */
  milestones: GitLabMilestone[];
  /** Release assets */
  assets: {
    /** Asset count */
    count: number;
    /** Asset sources */
    sources: GitLabAssetSource[];
    /** Asset links */
    links: GitLabAssetLink[];
  };
}

interface GitLabMilestone {
  /** Milestone ID */
  id: number;
  /** Milestone title */
  title: string;
  /** Milestone description */
  description: string;
  /** Milestone state */
  state: string;
  /** Milestone web URL */
  web_url: string;
}

interface GitLabAssetSource {
  /** Source format (zip, tar.gz, tar.bz2, tar) */
  format: string;
  /** Source download URL */
  url: string;
}

interface GitLabAssetLink {
  /** Asset link ID */
  id: number;
  /** Asset name */
  name: string;
  /** Asset URL */
  url: string;
  /** Asset type */
  link_type: string;
}

Repository Information

Methods for retrieving GitLab repository information and URLs.

/**
 * Get GitLab repository web URL
 * @returns Repository web URL string
 */
getWebUrl(): string;

/**
 * Get GitLab repository API URL
 * @returns Repository API URL string
 */
getApiUrl(): string;

/**
 * Get GitLab project information
 * @returns Promise resolving to project object
 */
getProject(): Promise<GitLabProject>;

interface GitLabProject {
  /** Project ID */
  id: number;
  /** Project name */
  name: string;
  /** Project path */
  path: string;
  /** Project full path */
  path_with_namespace: string;
  /** Project description */
  description: string;
  /** Project web URL */
  web_url: string;
  /** Project HTTP clone URL */
  http_url_to_repo: string;
  /** Project SSH clone URL */
  ssh_url_to_repo: string;
  /** Default branch */
  default_branch: string;
  /** Project visibility */
  visibility: string;
}

Authentication and Configuration

GitLab plugin authentication and configuration options.

interface GitLabOptions {
  /** Enable/disable GitLab plugin entirely */
  disabled?: boolean;
  
  /** Enable/disable GitLab release creation */
  release?: boolean;
  
  /** GitLab personal access token or CI job token for authentication */
  token?: string;
  
  /** Environment variable name for token (default: 'GITLAB_TOKEN') */
  tokenRef?: string;
  
  /** Token header type ('Private-Token' or 'Job-Token') */
  tokenHeader?: string;
  
  /** Release name template (supports context interpolation) */
  releaseName?: string;
  
  /** Release description/notes template (supports context interpolation) */
  releaseNotes?: string;
  
  /** Auto-generate release notes using GitLab's API */
  autoGenerate?: boolean;
  
  /** Asset files to upload (file paths or glob patterns) */
  assets?: string[];
  
  /** GitLab instance origin URL (for self-hosted GitLab) */
  origin?: string;
  
  /** Skip authentication and connectivity checks */
  skipChecks?: boolean;
  
  /** SSL/TLS security settings */
  secure?: boolean;
  
  /** Custom certificate authority file path */
  certificateAuthorityFile?: string;
  
  /** Environment variable for certificate authority file reference */
  certificateAuthorityFileRef?: string;
  
  /** Project milestones to associate with release */
  milestones?: string[];
  
  /** Use project IDs instead of paths in URLs */
  useIdsForUrls?: boolean;
  
  /** Use GitLab generic package repository for assets */
  useGenericPackageRepositoryForAssets?: boolean;
  
  /** HTTP proxy configuration */
  proxy?: string;
  
  /** Request timeout in milliseconds */
  timeout?: number;
  
  /** Number of retry attempts for failed requests */
  retries?: number;
  
  /** Minimum timeout between retries in milliseconds */
  retryMinTimeout?: number;
  
  /** Update existing release if tag already exists */
  update?: boolean;
  
  /** Comments configuration for issue/MR processing */
  comments?: {
    /** Submit comments on resolved issues */
    submit?: boolean;
    /** Include resolved issues in release notes */
    issue?: string;
    /** Include merged MRs in release notes */
    mr?: string;
  };
}

Usage Examples:

// Basic GitLab release configuration
const result = await runTasks({
  gitlab: {
    release: true,
    releaseName: "Release ${version}",
    assets: ["dist/*.zip", "docs/*.pdf"]
  }
});

// Advanced GitLab configuration with milestones
const result = await runTasks({
  gitlab: {
    release: true,
    releaseName: "🚀 ${name} v${version}",
    releaseNotes: "## Changes\n\n${changelog}\n\n## Installation\n\nnpm install ${name}@${version}",
    milestones: ["v19.0", "Release Candidate"],
    assets: [
      "dist/bundle.min.js",
      "dist/bundle.min.css",
      "docs/api.md"
    ],
    autoGenerate: true,
    update: true
  }
});

// Self-hosted GitLab configuration
const result = await runTasks({
  gitlab: {
    release: true,
    token: process.env.GITLAB_TOKEN,
    origin: "https://gitlab.internal.company.com",
    secure: false,  // For self-signed certificates
    certificateAuthorityFile: "/path/to/ca.crt"
  }
});

// GitLab CI/CD with job token
const result = await runTasks({
  gitlab: {
    release: true,
    tokenRef: "CI_JOB_TOKEN",
    tokenHeader: "Job-Token",
    useGenericPackageRepositoryForAssets: true
  }
});

Authentication Methods

The GitLab plugin supports multiple authentication methods:

  1. Personal Access Token: GITLAB_TOKEN environment variable or configuration
  2. Job Token: CI_JOB_TOKEN for GitLab CI/CD pipelines
  3. Custom Token Reference: Specify custom environment variable name
  4. Deploy Token: Limited scope token for releases

Asset Upload Options

The GitLab plugin provides two asset upload mechanisms:

  1. Release Links: Traditional links associated with releases
  2. Generic Package Repository: Upload to GitLab's package registry

Self-hosted GitLab Support

The plugin includes comprehensive support for self-hosted GitLab instances:

  • Custom Origins: Specify custom GitLab instance URLs
  • Certificate Handling: Support for custom CA certificates and self-signed certificates
  • Security Options: Configurable SSL/TLS verification
  • API Compatibility: Works with various GitLab versions

GitLab CI/CD Integration

The plugin is optimized for GitLab CI/CD environments:

  • Job Token Authentication: Automatic CI job token detection
  • Pipeline Variables: Integration with GitLab CI variables
  • Artifact Handling: Upload build artifacts as release assets
  • Milestone Integration: Associate releases with project milestones

Error Handling

The GitLab plugin includes robust error handling for:

  • Authentication Issues: Clear feedback for token problems
  • API Rate Limits: Automatic retry with exponential backoff
  • Network Connectivity: Timeout and retry logic for self-hosted instances
  • Asset Upload Failures: Individual asset retry without affecting release creation
  • SSL/TLS Issues: Detailed error messages for certificate problems

Context Variables

The GitLab plugin provides additional context variables:

  • ${releaseUrl} - URL of created GitLab release
  • ${projectId} - GitLab project ID
  • ${repo.host} - GitLab host (for self-hosted instances)
  • ${milestones} - Associated milestone names

Comparison with GitHub Plugin

Key differences from the GitHub plugin:

  • Milestones: GitLab releases can be associated with project milestones
  • Generic Packages: Alternative asset storage in package registry
  • Job Tokens: CI-specific authentication method
  • Project IDs: Option to use project IDs instead of paths in URLs
  • Self-hosted Focus: Enhanced support for on-premise GitLab instances

Install with Tessl CLI

npx tessl i tessl/npm-release-it

docs

cli-interface.md

configuration.md

core-orchestration.md

git-operations.md

github-integration.md

gitlab-integration.md

index.md

npm-publishing.md

plugin-system.md

tile.json