Recently, on a tip from one friend, they began to use Slack in the company. Immediately there was a question about his integration with Jira. I must say that Slack nominally has integration with Jira out of the box, but in fact it turned out that it does not handle all the events, is not configured at all and does not work at all as we would like. Therefore, it was decided to write your integration in php.
Requirements were formed as follows:
Must be processing all significant events of the Jira-task (Create, Update, Delete, Assign per user)
It should be possible to dissolve events from different projects through different channels.
It should be possible to send a personal message to the user when assigning a task to it.
An attempt was made to find a ready request handler from JiraWebHook and adequate php classes for working with SlackAPI. However, not a single decision was liked and it was decided to do everything completely independently. What happened - actually, here . Now a few words about what's inside. Everything consists of three classes:
JiraHookReceiver - gets data from Jira;
SlackWebhookSender - sends data to Slack (on the Slack side, it was decided to use IncomingHook integration for receiving messages as the simplest but meeting all the requirements set);
JiraSlackIntegration is a class that implements the actual logic of event handling and sending messages.
It unfolds simply:
The repository is cloned or files are copied;
Send the root of the host to the www folder;
Create a folder for log files in the www folder (default www / logs) and give write access to the user under which the script runs;
Add the “IncomingHook” integration to Slack and register the resulting URL into the JiraSlackIntegration class (line 14);
Add a new WebHook to Jira with a host URL;
Set the necessary settings for $ projectsToChannels and $ jiraUsersToSlack in the JiraSlackIntegration class.
That's all. Maybe someone will need it. I would be happy to comment additions.