Skip to content

GitLab Next

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • See what's new at GitLab
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
GitLab
GitLab
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 34,552
    • Issues 34,552
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 1,134
    • Merge Requests 1,134
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Metrics
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • GitLab.org
  • GitLabGitLab
  • Merge Requests
  • !4466

You need to sign in or sign up before continuing.
Merged
Opened Feb 09, 2018 by Yorick Peterse@yorickpeterse🎄Maintainer14 of 15 tasks completed14/15 tasks

Support for GitLab Chatops using Slash commands

  • Overview 60
  • Commits 1
  • Pipelines 17
  • Changes 40

What does this MR do?

This MR adds support for GitLab Chatops by scheduling a CI pipeline for every chat command. This allows one to define commands directly in .gitlab-ci.yml. For example:

---
echo:
  script:
    - 'echo "Your input was: $CHAT_INPUT"'
fortune:
  script:
    - 'fortune -s'
explain:
  script:
    - psql -h /home/yorickpeterse/Projects/gitlab/gdk-ee/postgresql -d gitlabhq_development -q -c "EXPLAIN (ANALYZE, BUFFERS) $CHAT_INPUT;"
fail:
  script:
    - exit 1

Using such a configuration file you can run commands by running /root-slash-command-here run explain select count(*) from users where root-slash-command-here is the root command (e.g. /gl-infra or /chatops-test).

Input to the commands is provided using the CHAT_INPUT environment variable. This variable is set to the text that comes after the command name (ignoring leading whitespace). In the above example that would be select count(*) from users.

Output is sent back in one of two ways:

  1. If it's small enough we just send it as-is (mentioning the user in the process).
  2. If the output is too large we send back a link to the build. Currently the limit is 3.5 KB as Slack enforces a limit of around 4 KB per message

Output produced also always contains links to the project, pipeline, and the build.

See commit 63b36051 for more details.

Screenshot

Screenshot_from_2018-02-27_18-15-17

TODO

  • Make sure that the code has some better documentation here and there
  • Double check the changes to see if all relevant code has tests
  • Make sure guests can't schedule pipelines via chat (IIRC this should already be covered but double checking doesn't hurt)

Does this MR meet the acceptance criteria?

  • Changelog entry added, if necessary
  • Documentation created/updated
  • API support added
  • Tests added for this feature/bug
  • Review
    • Has been reviewed by Backend
    • Has been reviewed by Database
  • Conform by the merge request performance guides
  • Conform by the style guides
  • Squashed related commits together
  • Internationalization required/considered
  • If paid feature, have we considered GitLab.com plan and how it works for groups and is there a design for promoting it to users who aren't on the correct plan
  • End-to-end tests pass (package-qa manual pipeline job)

What are the relevant issue numbers?

  • https://gitlab.com/gitlab-org/gitlab-ee/issues/4856
  • https://gitlab.com/gitlab-org/gitlab-ce/issues/34311
Edited Mar 07, 2018 by Kamil Trzciński
Assignee
Assign to
Reviewer
Request review from
10.6
Milestone
10.6 (Past due)
Assign milestone
Time tracking
Reference: gitlab-org/gitlab!4466
Source branch: chatops

Revert this merge request

This will create a new commit in order to revert the existing changes.

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.

Cherry-pick this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.