GitLab CI/CD: Architecting, Deploying, and Optimizing Pipelines
Optimization Security and Monitoring
ChatOps with Slack
In this guide, we’ll demonstrate how to integrate GitLab ChatOps into your Slack workspace. With GitLab ChatOps, you can trigger CI/CD pipelines, manage issues, and review job outputs—all without leaving Slack.
Requirements
- A GitLab project with the GitLab for Slack app installed and configured
- Enabled slash commands in Slack (Mattermost uses different commands)
Available Slash Commands
Use the /gitlab help
command to list all supported GitLab ChatOps slash commands in your workspace.
Slash Command | Description | Example |
---|---|---|
/gitlab [alias] issue show <id> | Display issue details | /gitlab demo-group/solar-system issue show 42 |
/gitlab [alias] issue new <title> <description> | Create a new issue | /gitlab demo-group/solar-system issue new "Bug" "Steps" |
/gitlab [alias] issue close <id> | Close an issue | /gitlab demo-group/solar-system issue close 42 |
/gitlab [alias] run <job-name> [--branch=<branch>] | Trigger a CI job | /gitlab demo-group/solar-system run test-suite |
/gitlab [alias] deploy <env> to <target-env> | Deploy environment | /gitlab demo-group/solar-system deploy staging to prod |
List Commands in Slack
In your GitLab notification channel (e.g., #gitlab-notifications
), type:
/gitlab help
Creating an Issue via ChatOps
You can quickly create issues directly in Slack:
Identify your project alias (group/project) set up during Slack integration.
Run the new-issue command:
/gitlab demos-group/solar-system issue new "Demo Title" <<Shift+Enter>> Trying out GitLab ChatOps commands using Slack.
Slack will confirm the issue creation. You can verify it in GitLab:
Running CI Jobs via ChatOps
Assuming your .gitlab-ci.yml
defines a unit_testing
job:
unit_testing:
stage: test
extends: .prepare_nodejs_environment
script:
- npm test
artifacts:
when: always
expire_in: 3 days
name: Moca-Test-Result
paths:
- test-results.xml
reports:
junit: test-results.xml
Trigger this job in Slack:
/gitlab demos-group/solar-system run unit_testing
If you need to run the job on a feature branch:
/gitlab demos-group/solar-system run unit_testing --branch="feature/setting-up-gitlab-ci"
Warning
If escaping special characters in branch names fails, you may temporarily change your project’s default branch in GitLab.
- Go to Settings > Repository > Default branch
- Select your feature branch and save
Once the default branch is updated, rerun without --branch
:
/gitlab demos-group/solar-system run unit_testing
Back in GitLab you’ll see the new pipeline logs:
Using docker image sha256:b20b249d538a41dfa3e9fd70479cad96a73240fc7df1eacd8de45 for node:17-alpine3.14 ...
$ npm install
up to date, audited 385 packages in 2s
45 packages are looking for funding
run `npm fund` for details
2 vulnerabilities (1 high, 1 critical)
...
$ npm test
> Solar [email protected] test
> mocha app-test.js --timeout 10000 --reporter mocha-junit-reporter --exit
Server successfully running on port - 3000
You’ll also receive job-completion notifications directly in Slack, keeping you informed without context switching.
References
Watch Video
Watch video content