shinekda.blogg.se

Slack bots
Slack bots












slack bots

I did not explain that what each method perform separately, but all the methods has method descriptions. but you need setup.py file(you can google it, how to create setup.py)Ĩ. you can build and deploy this code on any environment where it runs as a server. This slackbot can also use for handling multiple jenkins jobs, also can use different purposes (Ex: building projects from gitHub etc.) (not only handling jenkins jobs)ħ. if your jenkins job expecting parameters (Ex: project name, type of device, type of tests) here is the commands I use from the slack, ( enkins-bot jenkins enkins-bot helpĦ. understand that what code is doing, and probably you need to handle/add logic that what command you need to pass to slackbot to run the jenkins job.ĥ. you can change the command whatever you like but you need to update that in your slackbot.pyĤ. you can also invite in to slack channels/groups.ģ. if you dont’ see slackbot in your slack, please invite it into slack(just type and invite).

slack bots

check your Bot(jenkins-bot) is active in your slack. Important Notes:ġ.check the console logs, that slackbot started and up and running. Now that all of our code is in place we can run our SlackBot on the command line with the python slackbot.py command.

slack bots

Please download source code over here and make changes as per your needs. virtualenv slcakbot source slackbot/bin/activate pip install slackclientĪll the files and required code provided below, you can keep all methods in one file(slackbot.py) as well ( it’s up to you). Note: if you are on Mac, Linux, open terminal and go to your home directory or any working directory you like and run below commands.

  • Channels: This bot is currently in the following channels.(please create one slack channel in your installed slack if you don’t have any).
  • What this bot does: Let others on your team know what this bot is used for (optional).
  • Full Name: You can choose to display your bot’s full name rather than its username.
  • Customize Icon: Change the icon used for this bot.
  • Customize Name: Choose the username for this bot.
  • Do not publish bot user tokens in public code repositories.)

    slack bots

  • API Token : The library you are using will want an API token for your bot.(Be careful when sharing bot user tokens with applications.













  • Slack bots