← Gitlab + Go integrations

Run Go Code with Go API on New Mention (Instant) from Gitlab API

Pipedream makes it easy to connect APIs for Go, Gitlab and 1000+ other apps remarkably fast.

Trigger workflow on
New Mention (Instant) from the Gitlab API
Next, do this
Run Go Code with the Go API
No credit card required
Into to Pipedream
Watch us build a workflow
Watch us build a workflow
7 min
Watch now ➜

Trusted by 400,000+ developers from startups to Fortune 500 companies

Adyen logo
Brex logo
Carta logo
Checkr logo
Chameleon logo
DevRev logo
LinkedIn logo
Netflix logo
New Relic logo
OnDeck logo
Replicated logo
Scale AI logo
Teamwork logo
Warner Bros. logo
Xendit logo

Developers Pipedream

Getting Started

This integration creates a workflow with a Gitlab trigger and Go action. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Select this integration
  2. Configure the New Mention (Instant) trigger
    1. Connect your Gitlab account
    2. Select a Project ID
    3. Optional- Select a Username
  3. Configure the Run Go Code action
    1. Connect your Go account
  4. Deploy the workflow
  5. Send a test event to validate your setup
  6. Turn on the trigger

Details

This integration uses pre-built, source-available components from Pipedream's GitHub repo. These components are developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

Trigger

Description:Emit new event when you are @mentioned in a new commit, comment, issue or pull request
Version:0.1.0
Key:gitlab-new-mention

Gitlab Overview

Gitlab API allows developers to access the functionality of Gitlab. With the
Gitlab API, developers can integrate Gitlab with other applications, create
custom applications, or automate tasks.

Some examples of what you can build using the Gitlab API include:

  • Automate tasks such as creating and managing repositories
  • Integrate Gitlab with other applications such as your chat application
  • Create custom applications on top of Gitlab

Trigger Code

import gitlab from "../../gitlab.app.mjs";
import base from "../common/base.mjs";
import { eventTypes } from "../common/hook-events.mjs";

export default {
  ...base,
  key: "gitlab-new-mention",
  name: "New Mention (Instant)",
  description: "Emit new event when you are @mentioned in a new commit, comment, issue or pull request",
  version: "0.1.0",
  dedupe: "unique",
  type: "source",
  props: {
    ...base.props,
    username: {
      propDefinition: [
        gitlab,
        "assignee",
        (c) => ({
          projectId: c.projectId,
        }),
      ],
      label: "Username",
      description: "The GitLab Username whose mentions will emit events",
      withLabel: true,
    },
  },
  hooks: {
    ...base.hooks,
    async activate() {
      await this.activateHook([
        eventTypes.ISSUES_EVENTS,
        eventTypes.NOTE_EVENTS,
      ]);
    },
  },
  methods: {
    ...base.methods,
    isUserMentioned(mention) {
      const pattern = new RegExp(`\\B@${this.username.label}\\b`);
      const groomedAttributes = {
        ...mention,
        // We want to exclude some fields, since they do not map
        // to the content being updated, and could result in false
        // positives (e.g. if a URL contains `@someuser` in its path).
        url: "",
      };
      const changedSummary = JSON.stringify(groomedAttributes);
      return pattern.test(changedSummary);
    },
    generateMeta({
      user, mention,
    }) {
      const {
        id,
        created_at: createdAt,
      } = mention;
      const { username } = user;
      return {
        id,
        summary: `New mention of ${this.username.label} by ${username}`,
        ts: +new Date(createdAt),
      };
    },
    async emitEvent(event) {
      const {
        user,
        object_attributes: mention,
      } = event;
      // Gitlab doesn't offer a specific hook for "new label" events,
      // but such event can be deduced from the payload of "issues" events.
      if (this.isUserMentioned(mention)) {
        const meta = this.generateMeta({
          user,
          mention,
        });
        this.$emit(event, meta);
      }
    },
  },
};

Trigger Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
LabelPropTypeDescription
GitlabgitlabappThis component uses the Gitlab app.
N/Adb$.service.dbThis component uses $.service.db to maintain state between component invocations.
N/Ahttp$.interface.httpThis component uses $.interface.http to generate a unique URL when the component is first instantiated. Each request to the URL will trigger the run() method of the component.
Project IDprojectIdintegerSelect a value from the drop down menu.
UsernameusernamestringSelect a value from the drop down menu.

Trigger Authentication

Gitlab uses OAuth authentication. When you connect your Gitlab account, Pipedream will open a popup window where you can sign into Gitlab and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Gitlab API.

Pipedream requests the following authorization scopes when you connect your account:

apiread_userread_repositorywrite_repositoryread_registrysudoopenidprofileemail

About Gitlab

Project planning and source code management

Action

Description:Run any Go code and use any Go package available with a simple import. Refer to the [Pipedream Go docs](https://pipedream.com/docs/code/go) to learn more.
Version:0.0.2
Key:go-run-go-code

Action Code

import go from "../../go.app.mjs";

export default {
  name: "Run Go Code",
  version: "0.0.2",
  key: "go-run-go-code",
  description: "Run any Go code and use any Go package available with a simple import. Refer to the [Pipedream Go docs](https://pipedream.com/docs/code/go) to learn more.",
  props: {
    go,
  },
  type: "action",
  methods: {},
  async run({ $ }) {
    // Placeholder action for Go code app
  },
};

Action Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI.

LabelPropTypeDescription
GogoappThis component uses the Go app.

Action Authentication

The Go API does not require authentication.

About Go

Anything you can do in Go, you can do in a Pipedream Workflow. You can use any of Go packages available with a simple import.

More Ways to Connect Go + Gitlab

Run Go Code with Go API on New Review Request (Instant) from Gitlab API
Gitlab + Go
 
Try it
Run Go Code with Go API on New Milestone from Gitlab API
Gitlab + Go
 
Try it
Run Go Code with Go API on New Project from Gitlab API
Gitlab + Go
 
Try it
Run Go Code with Go API on New Merge Request (Instant) from Gitlab API
Gitlab + Go
 
Try it
Run Go Code with Go API on New Commit Comment (Instant) from Gitlab API
Gitlab + Go
 
Try it
New Commit (Instant) from the Gitlab API

Emit new event when a new commit is pushed to a branch

 
Try it
New Branch (Instant) from the Gitlab API

Emit new event when a new branch is created

 
Try it
New Project from the Gitlab API

Emit new event when a project (i.e. repository) is created

 
Try it
New Audit Event (Instant) from the Gitlab API

Emit new event when a new audit event is created

 
Try it
New Commit Comment (Instant) from the Gitlab API

Emit new event when a commit receives a comment

 
Try it
Create Branch with the Gitlab API

Create a new branch in the repository. See docs

 
Try it
Create Epic with the Gitlab API

Creates a new epic. See docs

 
Try it
Create issue with the Gitlab API

Creates a new issue. See docs

 
Try it
Edit Issue with the Gitlab API

Updates an existing project issue. See docs

 
Try it
Get Issue with the Gitlab API

Gets a single issue from repository. See docs

 
Try it