|
All checks were successful
continuous-integration/drone/push Build is passing
[TASK] Update module github.com/go-playground/webhooks/v6 (v6.2.0 to v6.4.0) See merge request lsascha/gitlab-slackbot!147 |
||
|---|---|---|
| db | ||
| docs/img | ||
| gitlabUtils | ||
| mergeRequest | ||
| settings | ||
| slackUtils | ||
| utils | ||
| .drone.yml | ||
| .env.template | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| docker-compose.yml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| main.go | ||
| README.md | ||
| renovate.json5 | ||
| runTests.bat | ||
| runTests.sh | ||
Gitlab Slackbot
Creates Gitlab Merge Request Messages in a Slack Channel.
Bot Configuration
All Configurations are made using Environment Variables.
-
Bot User OAuth Access Token (starts with "xoxb-")
SLACK_TOKEN= -
use Alphanumeric ID inside the Link to the Channel. (last part of
https://somename.slack.com/archives/CTY9R28F3so it isCTY9R28F3) you can get it by right-clicking on the channel and choosing "Copy channel-link"SLACK_CHANNEL_ID= -
Comma separated list of String replace pairs. (useful to replace special characters used in MR titles [for example in renovate the =>]) where a
:is used as separator.(example:
REPLACE_PAIRS==>:towill replace all=>withto)REPLACE_PAIRS= -
Secret provided in hook calls from gitlab
GITLAB_SECRET= -
Gitlab personal access token (requires API scope)
GITLAB_ACCESS_TOKEN= -
URL to Gitlab instance ("https://gitlab.com" for public gitlab) without "/" at the end.
GITLAB_URL= -
Comma separated list of Usernames, gitlab comments are ignored from. (useful for comments from Bots)
GITLAB_IGNORED_USERNAMES= -
"True" or "1" if the bot should add the Direct Merge Button to the message. (requires
GITLAB_ACCESS_TOKENandGITLAB_URL)DIRECT_MERGE=
GITLAB_ACCESS_TOKEN and GITLAB_URL are only used for the "Direct Merge" and "review" Buttons in the message.
If one of these are empty, no button will be added to the message.
Gitlab Configuration
-
Gitlab Hook URL needs to point to the URL
https://hostname-of-bot/webhooks. which needs to be accessible from the Internet. -
Add some random string to the Hooks
Secret Tokenand add the same to the environment variableGITLAB_SECRET -
The Hook in Gitlab needs to listen to
Comments(called Note events in API),Merge requests eventsandPipeline events. -
Optional for the "Direct Merge" Button:
- Create a User Access Token in the User Settings under
Access Tokens( urlhttps://gitlab.com/profile/personal_access_tokens). - Give it the Scope
api. - The User of the
GITLAB_ACCESS_TOKENneeds permissions to merge in the Repository for the Button work.
- Create a User Access Token in the User Settings under
Slack Configuration (https://api.slack.com/)
-
Create the Slack Token using Link https://api.slack.com/apps?new_classic_app=1 (You can
Update to Granular Scopeslater. After Scope Updates you need toReinstall App)-
Required Scopes are
chat:write.(TODO: confirm that this is enough. might require more Scopes).
-
-
Add the
Bot User OAuth Access Token(starts with "xoxb-") to theSLACK_TOKENenvironment variable ( see Bot Configuration) -
Finally, add the Bot User to the Slack Channel you want the Bot to Post to and add set the ID of the Slack channel to the
SLACK_CHANNEL_IDenvironment variable.- You can get the Slack Channel ID by right-clicking on the channel and choosing "Copy channel-link". The last part
that looks like
CTY9R28F3is the ID.
- You can get the Slack Channel ID by right-clicking on the channel and choosing "Copy channel-link". The last part
that looks like
-
Optional for the "Direct Merge" Button:
- Url for Slack Action Events
https://hostname-of-bot/actionsneeds to be accessible from the Internet if the " Direct Merge" Button should be used. - Under
Interactive ComponentsEnableInteractivityand add thehttps://hostname-of-bot/actionsasRequest URL
- Url for Slack Action Events
Used Emojis inside the Slack Messages
Since currently the messages can not be configured, make sure the following emojis are available in Slack
:bust_in_silhouette:(Slack Default):anatomical_heart:(Slack Default):hammer_and_wrench:(Slack Default):heavy_check_mark:(Slack Default):eyes:(Slack Default):speech_balloon:(Slack Default):no-brainer:(Recommended:
):merged:(Recommended:
)
