承接 kommuna/jirawebhook 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kommuna/jirawebhook

Composer 安装命令:

composer require kommuna/jirawebhook

包简介

PHP classes for Atlassian Jira webhook data structure with events

README 文档

README

This is PHP library for processing and handling Atlassian JIRA webhook data.

It contains classes that can parse data from JIRA webhooks, create listeners for custom events and interface for creating converters for parsed data.

The package is meant to be used with the Vicky slackbot, but it can also be used independently.

Installation

With composer, create a new composer.json file and add the following code:

{
    "minimum-stability" : "dev",
    "require": {
        "kommuna/jirawebhook": "dev-master"
    }
}

Then run command composer install.

Usage

JIRA data events

To create a new event use following example code:

use JiraWebhook\JiraWebhook;
use JiraWebhook\Models\JiraWebhookData;

require __DIR__.'/vendor/autoload.php';
$config = require '/etc/vicky/config.php';

$jiraWebhook = new JiraWebhook();

$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());
}

JIRA data converters

To create a new converter create a new class that implements the JiraWebhookDataConverter interface. Then to set and use a new converter use the following example code:

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);

Please refer to Slack's documentation for message formatting for more details.

Testing

Run vendor/bin/phpunit or just phpunit if you have it installed globally.

统计信息

  • 总下载量: 300
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 4
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: Unlicense
  • 更新时间: 2017-02-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固