The application integrating GitLab with Telegram.
The application listens for GitLab webhooks and calls the Telegram Bot API.
- Comment on merge request
- Comment on code snippet
- Merge request events
- Pipeline events (
'failed'
event only)
- Plan the endpoint for the application to run.
- Setup GitLab webhooks and obtain a GitLab secret token. Use the following url as a webhook target:
<your_endpoint>/gitlab_hook
, e.g. https://my-hook-endpoint.com/gitlab_hook - Setup a Telegram bot and obtain a
Bot token
- Setup a Telegram channel to which your bot would post messages
- Configure and deploy the app, see the
Configuration reference
section below
If you're familiar with the .NET Core configuration framework
Use any of the standard ways to provide the app configuration:
- appsettigns.json
- appsettings.{environment}.json
- environment variables
- command line arguments
There are several ways to configure a .NET Core application
appsettings.json
file - normally contains the most of the configuration.appsettings.{environment}.json
file - may be used to make some environment-dependent configuration overrides. The environment name normally comes from theASPNETCORE_ENVIRONEMNT
environment variable or from an--environment
command line arg. By-default the environment name isProduction
, so the filename would be theappsettings.production.json
.- Environment variables. Every setting from the
appsettings.json
may be overriden by an environment variable, having a name, same to the setting name inappsettings.json
. The:
symbol in a variable name is used as a hierarchy level separator. E.g. configuration settingTGram > Connection > Timeout
may be overriden by an environemnt variableTGRAM:CONNECTION:TIMEOUT
. - Command line arguments. Every setting from the
appsettings.json
may be overriden by a command-line key. The:
symbol in a key name is used as a hierarchy-level separator. E.g. configuration settingTGram > Connection > Timeout
may be overriden by a--tgram:connection:timeout
parameter.
- Ensure you have the runtime of a compatible version installed. At the moment the application was developed, the
2.2.x
version of the runtime was current. Pay attention you don't need the whole SDK to run the app - a bare runtime is enough. - run
dotnet TGramWeb.dll
, optionally providing command-line args. e.g:dotnet TGramWeb.dll --urls http://localhost:9000 --environment azure
A set of addresses the app would be listening at. A semicolon ;
may be used as a separator for multiple addresses. E.g. http://localhost:5000;https://localhost:5001
appsettings.json | Command line | Env variable |
---|---|---|
n/a | --urls | ASPNETCORE_URLS |
Determines the application environment. The default value is Production
appsettings.json | Command line | Env variable |
---|---|---|
n/a | --environment | ASPNETCORE_ENVIRONMENT |
A secure token you obtain when configuring a gitlab web hook.
appsettings.json | Command line | Env variable |
---|---|---|
Gitlab>Token | --gitlab:token | GITLAB:TOKEN |
Address of the telegram API. Normally https://api.telegram.org
appsettings.json | Command line | Env variable |
---|---|---|
TGram>Endpoint | --tgram:endpoint | TGRAM:ENDPOINT |
Telegram bot token you obtain when creating a bot.
appsettings.json | Command line | Env variable |
---|---|---|
TGram>Token | --trgram:token | TGRAM:TOKEN |
Telegram channel name. E.g. @mytgramchannel
appsettings.json | Command line | Env variable |
---|---|---|
TGram>Channel | --tgram:channel | TGRAM:CHANNEL |
Connection timeout when trying to send a message to telegram.
appsettings.json | Command line | Env variable |
---|---|---|
TGram>Connection>Timeout | --tgram:connection:timeout | TGRAM:CONNECTION:TIMEOUT |
Number of attempts to send a message to telegram before giving up.
appsettings.json | Command line | Env variable |
---|---|---|
TGRAM:CONNECTION:ATTEMPTS | --tgram:connection:attempts | TGRAM:CONNECTION:ATTEMPTS |
An interval between telegram call attempts.
appsettings.json | Command line | Env variable |
---|---|---|
TGram>Connection>Interval | --tgram:connection:interval | TGRAM:CONNECTION:INTERVAL |
A localhost address used to communicate between the web server and internal message handlers.
appsettings.json | Command line | Env variable |
---|---|---|
Daemon>Address | --daemon:address | DAEMON:ADDRESS |
appsettings.json | Command line | Env variable |
---|---|---|
Daemon>ThreadCount | --daemon:threadcount | DAEMON:THREADCOUNT |
Serilog standard configuration. See here.
appsettings.json | Command line | Env variable |
---|---|---|
Serilog>... | --serilog:... | SERILOG:... |