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.
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:
- If it's small enough we just send it as-is (mentioning the user in the process).
- 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.
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
API support added
Tests added for this feature/bug
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
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-qamanual pipeline job)