1. Go to this page and download the library: Download kommuna/jirawebhook library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kommuna / jirawebhook example snippets
use JiraWebhook\JiraWebhook;
use JiraWebhook\Models\JiraWebhookData;
bhook();
$jiraWebhook->addListener('jira:event_name', function($e, $data)
{
/**
* Your code here
*/
});
try {
$f = fopen('php://input', 'r');
$data = stream_get_contents($f);
if (!$data) {
throw new JiraWebhookException('There is no data in the Jira webhook');
}
$jiraWebhook->run();
} catch (\Exception $e) {
error_log($e->getMessage());
}
use JiraWebhook\JiraWebhookDataConverter;
use JiraWebhook\Models\JiraWebhookData;
class NewConverterClass implements JiraWebhookDataConverter
{
public function convert(JiraWebhookData $data)
{
$issue = $data->getIssue();
$assigneeName = $issue->getAssignee()->getName();
$comment = $issue->getIssueComments()->getLastComment();
$message = vsprintf(
":no_entry_sign: <%s|%s> %s: %s ➠ @%s\n@%s ➠ %s",
[
$issue->getUrl(),
$issue->getKey(),
$issue->getStatusName(),
$issue->getSummary(),
$assigneeName,
$comment->getAuthor()->getName(),
$comment->getBody(0, 178)
]
);
return $message;
}
}
JiraWebhook::setConverter('converterName', new NewConverterClass());
$message = JiraWebhook::convert('converterName', $data);
unit
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.