Skip to main content
Glama

gitlab_trigger_pipeline

Trigger a new GitLab CI/CD pipeline for a specific branch or ref to automate code testing and deployment processes.

Instructions

Triggers a new pipeline for a specific branch/ref.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesThe path of the GitLab project.
refYesThe branch or ref to trigger the pipeline for.
variablesNoOptional: Pipeline variables as key-value pairs.

Implementation Reference

  • Core handler function implementing the gitlab_trigger_pipeline tool. Posts to GitLab API to create a new pipeline for the specified project and ref, with optional variables.
    // New tool: Trigger Pipeline
    async triggerPipeline(projectPath: string, ref: string, variables?: Record<string, string>): Promise<any> {
      const encodedProjectPath = encodeURIComponent(projectPath);
      const body: any = { ref };
      if (variables) {
        body.variables = Object.entries(variables).map(([key, value]) => ({ key, value }));
      }
      return this.callGitLabApi<any>(
        `projects/${encodedProjectPath}/pipeline`,
        'POST',
        body,
      );
    }
  • src/index.ts:697-717 (registration)
    Registers the gitlab_trigger_pipeline tool in the MCP tools list, including name, description, and input schema.
      name: 'gitlab_trigger_pipeline',
      description: 'Triggers a new pipeline for a specific branch/ref.',
      inputSchema: {
        type: 'object',
        properties: {
          projectPath: {
            type: 'string',
            description: 'The path of the GitLab project.',
          },
          ref: {
            type: 'string',
            description: 'The branch or ref to trigger the pipeline for.',
          },
          variables: {
            type: 'object',
            description: 'Optional: Pipeline variables as key-value pairs.',
          },
        },
        required: ['projectPath', 'ref'],
      },
    },
  • src/index.ts:1840-1854 (registration)
    Dispatch handler in the MCP server request handler that calls the GitLab service's triggerPipeline method for the gitlab_trigger_pipeline tool.
    case 'gitlab_trigger_pipeline': {
      if (!gitlabService) {
        throw new Error('GitLab service is not initialized.');
      }
      const { projectPath, ref, variables } = args as { projectPath: string; ref: string; variables?: Record<string, string> };
      const result = await gitlabService.triggerPipeline(projectPath, ref, variables);
      return {
        content: [
          {
            type: 'text',
            text: `Pipeline triggered successfully: ${JSON.stringify(result, null, 2)}`,
          },
        ],
      };
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/HainanZhao/mcp-gitlab-jira'

If you have feedback or need assistance with the MCP directory API, please join our Discord server