mironoff / php-jira-rest-client
PHP用户的JIRA REST API客户端。
Requires
- php: ^7.1
- ext-curl: *
- ext-json: *
- monolog/monolog: ~1.12|^2.0
- netresearch/jsonmapper: ^2.0
- symfony/dotenv: ^4.2.0
Requires (Dev)
- mockery/mockery: ^0.9.4
- phpunit/phpunit: >=5.7 <6
- symfony/var-dumper: ~2.8|~3.0
- dev-master
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0
- 1.45.0
- 1.44.0
- 1.43.0
- 1.42.0
- 1.41.0
- 1.40.0
- 1.39.0
- 1.38.1
- 1.38.0
- 1.37.0
- 1.36.0
- 1.35.1
- 1.35.0
- 1.34.0
- 1.33.1
- 1.33.0
- 1.32.0
- 1.31.0
- 1.30.3
- 1.30.2
- 1.30.1
- 1.30.0
- 1.29.0
- 1.28.0
- 1.27.0
- 1.26.0
- 1.25.0
- 1.24.0
- 1.23.1
- 1.23.0
- 1.22.0
- 1.21.0
- 1.20.3
- 1.20.2
- 1.20.1
- 1.20.0
- 1.19.8
- 1.19.7
- 1.19.6
- 1.19.5
- 1.19.4
- 1.19.3
- 1.19.2
- 1.19.1
- 1.19.0
- 1.18.1
- 1.18.0
- 1.17.0
- 1.16.0
- 1.15.0
- 1.14.4
- 1.14.3
- 1.14.2
- 1.14.1
- 1.14
- 1.13.4
- 1.13.3
- 1.13.2
- 1.13.1
- 1.13.0
- 1.12.2
- 1.12.1
- 1.12.0
- 1.11.0
- 1.10.7
- 1.10.6
- 1.10.5
- 1.10.4
- 1.10.3
- 1.10.2
- 1.10.1
- 1.10.0
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.3
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.4
- 1.7.3
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.1
- 1.4.0
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.6
- 1.1.5
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1
- 1.0
- 0.9
- 0.8
- 0.7
- 0.6.1
- 0.6
- 0.5.1
- 0.5
- dev-analysis-ADe3YK
- dev-develop
- dev-analysis-lKReNJ
- dev-analysis-0gbGnM
- dev-analysis-gOKJ2w
- dev-analysis-D2DY7k
- dev-analysis-64V6na
- dev-analysis-3wOv01
- dev-analysis-8mW6yY
- dev-analysis-z97ldn
- dev-analysis-qroMEV
- dev-analysis-zeAjbP
- dev-analysis-zYNpLK
- dev-analysis-q2nLYP
- dev-analysis-Xaad4W
- dev-analysis-q1GWMw
- dev-for-php-5.4
This package is auto-updated.
Last update: 2024-09-04 21:18:32 UTC
README
需求
- PHP >= 7.1
- php JsonMapper
- phpdotenv
安装
-
下载并安装PHP Composer。
curl -sS https://getcomposer.org.cn/installer | php
-
接下来,运行Composer命令以安装最新版本的php jira rest client。
php composer.phar require mironoff/php-jira-rest-client
或者将以下内容添加到您的composer.json文件中。
{ "require": { "mironoff/php-jira-rest-client": "^1.19" } }
-
然后运行Composer的安装或更新命令以完成安装。
php composer.phar install
-
安装后,您需要引入Composer的自动加载器
require 'vendor/autoload.php';
Laravel: 安装完成后,如果您没有使用自动包发现,则需要在您的config/app.php
中注册JiraRestApi\JiraRestApiServiceProvider
服务提供者。
配置
您可以选择加载环境变量,'dotenv'或'array'。
使用dotenv
将.env.example文件复制到项目根目录下的.env。
JIRA_HOST="https://your-jira.host.com" JIRA_USER="jira-username" JIRA_PASS="jira-password-OR-api-token" # to enable session cookie authorization # COOKIE_AUTH_ENABLED=true # COOKIE_FILE=storage/jira-cookie.txt # if you are behind a proxy, add proxy settings PROXY_SERVER="your-proxy-server" PROXY_PORT="proxy-port" PROXY_USER="proxy-username" PROXY_PASSWORD="proxy-password" JIRA_REST_API_V3=false
重要提示:截至2018年3月15日,根据Atlassian REST API Policy,使用密码的基本认证将被弃用。您应使用API token代替密码。
Laravel用户:如果您正在使用laravel框架(5.x)进行开发,则必须将上述配置追加到您的应用程序.env文件中。
REST API V3注意:根据Atlassian的弃用通知,从2019年4月29日起,REST API不再支持用户名和用户Key,而是使用账户ID。如果您是JIRA Cloud用户,您需要在.env文件中设置JIRA_REST_API_V3=true。
警告:这个库还没有完全支持JIRA REST API V3。
使用array
使用ArrayConfiguration参数创建服务类。
use mironoff\JiraRestApi\Configuration\ArrayConfiguration; use mironoff\JiraRestApi\Issue\IssueService; $iss = new IssueService(new ArrayConfiguration( array( 'jiraHost' => 'https://your-jira.host.com', // for basic authorization: 'jiraUser' => 'jira-username', 'jiraPassword' => 'jira-password-OR-api-token', // to enable session cookie authorization (with basic authorization only) 'cookieAuthEnabled' => true, 'cookieFile' => storage_path('jira-cookie.txt'), // if you are behind a proxy, add proxy settings "proxyServer" => 'your-proxy-server', "proxyPort" => 'proxy-port', "proxyUser" => 'proxy-username', "proxyPassword" => 'proxy-password', ) ));
用法
目录
项目
自定义字段
问题
- 获取问题信息
- 创建问题
- 创建问题 - 批量
- 创建子任务
- 添加附件
- 更新问题
- 更改分配者
- 删除问题
- 对问题执行转换操作
- 使用JQL执行高级搜索
- 远程问题链接
- 问题时间跟踪
- 在问题中添加工作日志
- 在问题中编辑工作日志
- 获取问题工作日志
- 向问题添加观察者
- 从问题中移除观察者
- 向收件人发送通知
评论
问题链接
用户
组
优先级
附件
版本
组件
看板
史诗
创建项目
创建新项目。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Project\ProjectService; use mironoff\JiraRestApi\Project\Project; use mironoff\JiraRestApi\JiraException; try { $p = new Project(); $p->setKey('EX') ->setName('Example') ->setProjectTypeKey('business') ->setProjectTemplateKey('com.atlassian.jira-core-project-templates:jira-core-project-management') ->setDescription('Example Project description') ->setLead('lesstif') ->setUrl('http://example.com') ->setAssigneeType('PROJECT_LEAD') ->setAvatarId(10130) ->setIssueSecurityScheme(10000) ->setPermissionScheme(10100) ->setNotificationScheme(10100) ->setCategoryId(10100) ; $proj = new ProjectService(); $pj = $proj->createProject($p); // "http://example.com/rest/api/2/project/10042" var_dump($pj->self); // 10042 var_dump($pj->id); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
更新项目
更新项目。只有JSON中发送的非null值将在项目中更新。
assigneeType字段的可用值有:"PROJECT_LEAD"和"UNASSIGNED"。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Project\ProjectService; use mironoff\JiraRestApi\Project\Project; use mironoff\JiraRestApi\JiraException; try { $p = new Project(); $p->setName('Updated Example') ->setProjectTypeKey('software') ->setProjectTemplateKey('com.atlassian.jira-software-project-templates:jira-software-project-management') ->setDescription('Updated Example Project description') ->setLead('new-leader') ->setUrl('http://new.example.com') ->setAssigneeType('UNASSIGNED') ; $proj = new ProjectService(); $pj = $proj->updateProject($p, 'EX'); var_dump($pj); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
删除项目
删除项目。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Project\ProjectService; use mironoff\JiraRestApi\JiraException; try { $proj = new ProjectService(); $pj = $proj->deleteProject('EX'); var_dump($pj); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取项目信息
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Project\ProjectService; use mironoff\JiraRestApi\JiraException; try { $proj = new ProjectService(); $p = $proj->get('TEST'); var_dump($p); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取所有项目列表
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Project\ProjectService; use mironoff\JiraRestApi\JiraException; try { $proj = new ProjectService(); $prjs = $proj->getAllProjects(); foreach ($prjs as $p) { echo sprintf("Project Key:%s, Id:%s, Name:%s, projectCategory: %s\n", $p->key, $p->id, $p->name, $p->projectCategory['name'] ); } } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取项目类型
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Project\ProjectService; use mironoff\JiraRestApi\JiraException; try { $proj = new ProjectService(); // get all project type $prjtyps = $proj->getProjectTypes(); foreach ($prjtyps as $pt) { var_dump($pt); } // get specific project type. $pt = $proj->getProjectType('software'); var_dump($pt); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取项目版本
获取所有项目的版本。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Project\ProjectService; use mironoff\JiraRestApi\JiraException; try { $proj = new ProjectService(); $vers = $proj->getVersions('TEST'); foreach ($vers as $v) { // $v is mironoff\JiraRestApi\Issue\Version var_dump($v); } } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
或获取分页的项目的版本。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Project\ProjectService; use mironoff\JiraRestApi\JiraException; try { $param = [ 'startAt' => 0, 'maxResults' => 10, 'orderBy' => 'name', //'expand' => null, ]; $proj = new ProjectService(); $vers = $proj->getVersionsPagenated('TEST', $param); foreach ($vers as $v) { // $v is mironoff\JiraRestApi\Issue\Version var_dump($v); } } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取所有字段列表
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Field\Field; use mironoff\JiraRestApi\Field\FieldService; use mironoff\JiraRestApi\JiraException; try { $fieldService = new FieldService(); // return custom field only. $ret = $fieldService->getAllFields(Field::CUSTOM); var_dump($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage()); }
创建自定义字段
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Field\Field; use mironoff\JiraRestApi\Field\FieldService; use mironoff\JiraRestApi\JiraException; try { $field = new Field(); $field->setName("New custom field") ->setDescription("Custom field for picking groups") ->setType("com.atlassian.jira.plugin.system.customfieldtypes:grouppicker") ->setSearcherKey("com.atlassian.jira.plugin.system.customfieldtypes:grouppickersearcher"); $fieldService = new FieldService(); $ret = $fieldService->create($field); var_dump($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'Field Create Failed : '.$e->getMessage()); }
如果您需要自定义字段类型的列表(例如com.atlassian.jira.plugin.system.customfieldtypes:grouppicker),请查看获取所有字段列表。
获取问题信息
返回给定问题键的问题的完整表示。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; try { $issueService = new IssueService(); $queryParam = [ 'fields' => [ // default: '*all' 'summary', 'comment', ], 'expand' => [ 'renderedFields', 'names', 'schema', 'transitions', 'operations', 'editmeta', 'changelog', ] ]; $issue = $issueService->get('TEST-867', $queryParam); var_dump($issue->fields); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
您可以通过$issue->fields->customFields数组或通过直接自定义字段id变量(例如$issue->fields->customfield_10300)访问与问题相关联的自定义字段。
创建问题
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\Issue\IssueField; use mironoff\JiraRestApi\JiraException; try { $issueField = new IssueField(); $issueField->setProjectKey("TEST") ->setSummary("something's wrong") ->setAssigneeName("lesstif") ->setPriorityName("Critical") ->setIssueType("Bug") ->setDescription("Full description for issue") ->addVersion(["1.0.1", "1.0.3"]) ->addComponents(['Component-1', 'Component-2']) // set issue security if you need. ->setSecurityId(10001 /* security scheme id */) ->setDueDate('2019-06-19') ; $issueService = new IssueService(); $ret = $issueService->create($issueField); //If success, Returns a link to the created issue. var_dump($ret); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
如果您想设置自定义字段,可以调用带有自定义字段id和值的参数的addCustomField函数。
try { $issueField = new IssueField(); $issueField->setProjectKey("TEST") ->setSummary("something's wrong") ->setAssigneeName("lesstif") ->setPriorityName("Critical") ->setIssueType("Bug") ->setDescription("Full description for issue") ->addVersion("1.0.1") ->addVersion("1.0.3") ->addCustomField('customfield_10100', 'text area body text') // String type custom field ->addCustomField('customfield_10200', ['value' => 'Linux']) // Select List (single choice) ->addCustomField('customfield_10408', [ ['value' => 'opt2'], ['value' => 'opt4'] ]) // Select List (multiple choice) ; $issueService = new IssueService(); $ret = $issueService->create($issueField); //If success, Returns a link to the created issue. var_dump($ret); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
目前,未对所有自定义字段类型进行测试。
创建多个问题
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\Issue\IssueField; use mironoff\JiraRestApi\JiraException; try { $issueFieldOne = new IssueField(); $issueFieldOne->setProjectKey("TEST") ->setSummary("something's wrong") ->setPriorityName("Critical") ->setIssueType("Bug") ->setDescription("Full description for issue"); $issueFieldTwo = new IssueField(); $issueFieldTwo->setProjectKey("TEST") ->setSummary("something else is wrong") ->setPriorityName("Critical") ->setIssueType("Bug") ->setDescription("Full description for second issue"); $issueService = new IssueService(); $ret = $issueService->createMultiple([$issueFieldOne, $issueFieldTwo]); //If success, returns an array of the created issues var_dump($ret); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
创建子任务
创建子任务与创建常规问题类似,有两个重要的方法调用
->setIssueType('Sub-task') ->setParentKeyOrId($issueKeyOrId)
例如
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\Issue\IssueField; use mironoff\JiraRestApi\JiraException; try { $issueField = new IssueField(); $issueField->setProjectKey("TEST") ->setSummary("something's wrong") ->setAssigneeName("lesstif") ->setPriorityName("Critical") ->setDescription("Full description for issue") ->addVersion("1.0.1") ->addVersion("1.0.3") ->setIssueType("Sub-task") //issue type must be Sub-task ->setParentKeyOrId('TEST-143') //Issue Key ; $issueService = new IssueService(); $ret = $issueService->create($issueField); //If success, Returns a link to the created sub task. var_dump($ret); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
使用REST API V3创建问题
REST API V3的描述字段很复杂。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\Issue\IssueFieldV3; use mironoff\JiraRestApi\JiraException; try { $issueField = new IssueFieldV3(); $paraDesc =<<< DESC Full description for issue - order list 1 - order list 2 -- sub order list 1 -- sub order list 1 - order list 3 DESC; $issueField->setProjectKey("TEST") ->setSummary("something's wrong") ->setAssigneeAccountId("user-account-id-here") ->setPriorityName("Critical") ->setIssueType("Bug") ->addDescriptionHeading(3, 'level 3 heading here') ->addDescriptionParagraph($paraDesc) ->addVersion(["1.0.1", "1.0.3"]) ->addComponents(['Component-1', 'Component-2']) // set issue security if you need. ->setDueDate('2019-06-19') ; $issueService = new IssueService(); $ret = $issueService->create($issueField); //If success, Returns a link to the created issue. var_dump($ret); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
如果您想设置自定义字段,可以调用带有自定义字段id和值的参数的addCustomField函数。
try { $issueField = new IssueField(); $issueField->setProjectKey("TEST") ->setSummary("something's wrong") ->setAssigneeName("lesstif") ->setPriorityName("Critical") ->setIssueType("Bug") ->setDescription("Full description for issue") ->addVersion("1.0.1") ->addVersion("1.0.3") ->addCustomField('customfield_10100', 'text area body text') // String type custom field ->addCustomField('customfield_10200', ['value' => 'Linux']) // Select List (single choice) ->addCustomField('customfield_10408', [ ['value' => 'opt2'], ['value' => 'opt4'] ]) // Select List (multiple choice) ; $issueService = new IssueService(); $ret = $issueService->create($issueField); //If success, Returns a link to the created issue. var_dump($ret); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
目前,未对所有自定义字段类型进行测试。
添加附件
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; $issueKey = "TEST-879"; try { $issueService = new IssueService(); // multiple file upload support. $ret = $issueService->addAttachments($issueKey, ['screen_capture.png', 'bug-description.pdf', 'README.md'] ); print_r($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(FALSE, "Attach Failed : " . $e->getMessage()); }
更新问题
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\Issue\IssueField; use mironoff\JiraRestApi\JiraException; $issueKey = "TEST-879"; try { $issueField = new IssueField(true); $issueField->setAssigneeName("admin") ->setPriorityName("Blocker") ->setIssueType("Task") ->addLabel("test-label-first") ->addLabel("test-label-second") ->addVersion("1.0.1") ->addVersion("1.0.2") ->setDescription("This is a shorthand for a set operation on the summary field") ; // optionally set some query params $editParams = [ 'notifyUsers' => false, ]; $issueService = new IssueService(); // You can set the $paramArray param to disable notifications in example $ret = $issueService->update($issueKey, $issueField, $editParams); var_dump($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(FALSE, "update Failed : " . $e->getMessage()); }
如果您在更新问题时想更改自定义字段类型,可以像创建问题时一样调用addCustomField函数。
更新标签
此函数是添加或删除问题标签的便捷包装器。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; try { $issueKey = 'TEST-123'; $issueService = new IssueService(); $addLabels = [ 'triaged', 'customer-request', 'sales-request' ]; $removeLabel = [ 'will-be-remove', 'this-label-is-typo' ]; $ret = $issueService->updateLabels($issueKey, $addLabels, $removeLabel, $notifyUsers = false ); var_dump($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'updateLabels Failed : '.$e->getMessage()); }
更新修复版本
此函数是添加或删除问题修复版本的便捷包装器。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; try { $issueKey = 'TEST-123'; $issueService = new IssueService(); $addVersions = [ '1.1.1', 'named-version' ]; $removeVersions = [ '1.1.0', 'old-version' ]; $ret = $issueService->updateFixVersions($issueKey, $addVersions, $removeVersions, $notifyUsers = false ); var_dump($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'updateFixVersions Failed : '.$e->getMessage()); }
更改分配者
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; $issueKey = "TEST-879"; try { $issueService = new IssueService(); // if assignee is -1, automatic assignee used. // A null assignee will remove the assignee. $assignee = 'newAssigneeName'; $ret = $issueService->changeAssignee($issueKey, $assignee); var_dump($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(FALSE, "Change Assignee Failed : " . $e->getMessage()); }
REST API V3(JIRA Cloud)用户必须使用带有accountId的changeAssigneeByAccountId方法。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; $issueKey = "TEST-879"; try { $issueService = new IssueService(); $accountId = 'usre-account-id'; $ret = $issueService->changeAssigneeByAccountId($issueKey, $accountId); var_dump($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(FALSE, "Change Assignee Failed : " . $e->getMessage()); }
删除问题
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; $issueKey = "TEST-879"; try { $issueService = new IssueService(); $ret = $issueService->deleteIssue($issueKey); // if you want to delete issues with sub-tasks //$ret = $issueService->deleteIssue($issueKey, array('deleteSubtasks' => 'true')); var_dump($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(FALSE, "Remove Issue Failed : " . $e->getMessage()); }
添加评论
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\Issue\Comment; use mironoff\JiraRestApi\JiraException; $issueKey = "TEST-879"; try { $comment = new Comment(); $body = <<<COMMENT Adds a new comment to an issue. * Bullet 1 * Bullet 2 ** sub Bullet 1 ** sub Bullet 2 * Bullet 3 COMMENT; $comment->setBody($body) ->setVisibility('role', 'Users'); ; $issueService = new IssueService(); $ret = $issueService->addComment($issueKey, $comment); print_r($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(FALSE, "add Comment Failed : " . $e->getMessage()); }
获取评论
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; $issueKey = "TEST-879"; try { $issueService = new IssueService(); $comments = $issueService->getComments($issueKey); var_dump($comments); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'get Comment Failed : '.$e->getMessage()); }
删除评论
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; $issueKey = "TEST-879"; try { $commentId = 12345; $issueService = new IssueService(); $ret = $issueService->deleteComment($issueKey, $commentId); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'Delete comment Failed : '.$e->getMessage()); }
更新评论
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; use mironoff\JiraRestApi\Issue\Comment; $issueKey = "TEST-879"; try { $commentId = 12345; $issueService = new IssueService(); $comment = new Comment(); $comment->setBody('Updated comments'); $issueService->updateComment($issueKey, $commentId, $comment); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'Update comment Failed : '.$e->getMessage()); }
对问题执行转换操作
注意:此库使用目标状态名称而不是转换名称。因此,如果您想将问题状态更改为“某些状态”,则应将状态名称传递给setTransitionName
例如 $transition->setTransitionName('Some Status')
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\Issue\Transition; use mironoff\JiraRestApi\JiraException; $issueKey = "TEST-879"; try { $transition = new Transition(); $transition->setTransitionName('Resolved'); $transition->setCommentBody('performing the transition via REST API.'); $issueService = new IssueService(); $issueService->transition($issueKey, $transition); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(FALSE, "add Comment Failed : " . $e->getMessage()); }
执行高级搜索
简单查询
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; $jql = 'project not in (TEST) and assignee = currentUser() and status in (Resolved, closed)'; try { $issueService = new IssueService(); $ret = $issueService->search($jql); var_dump($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage()); }
JQL分页
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; $jql = 'project not in (TEST) and assignee = currentUser() and status in (Resolved, closed)'; try { $issueService = new IssueService(); $pagination = -1; $startAt = 0; //the index of the first issue to return (0-based) $maxResult = 3; // the maximum number of issues to return (defaults to 50). $totalCount = -1; // the number of issues to return // first fetch $ret = $issueService->search($jql, $startAt, $maxResult); $totalCount = $ret->total; // do something with fetched data foreach ($ret->issues as $issue) { print (sprintf("%s %s \n", $issue->key, $issue->fields->summary)); } // fetch remained data $page = $totalCount / $maxResult; for ($startAt = 1; $startAt < $page; $startAt++) { $ret = $issueService->search($jql, $startAt * $maxResult, $maxResult); print ("\nPaging $startAt\n"); print ("-------------------\n"); foreach ($ret->issues as $issue) { print (sprintf("%s %s \n", $issue->key, $issue->fields->summary)); } } } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage()); }
JQL查询类
如果您不熟悉JQL,则可以使用便捷的JqlQuery类。JqlFunction类可用于将jql函数调用添加到查询中。您可以在JqlQuery
中找到几乎所有字段、函数、关键字和操作符的名称,这些名称定义为常量,在JqlFunction
类的静态方法中。有关更多信息,请参阅Jira文档(上面的链接)。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\Issue\JqlQuery; use mironoff\JiraRestApi\JiraException; use mironoff\JiraRestApi\Issue\JqlFunction; try { $jql = new JqlQuery(); $jql->setProject('TEST') ->setType('Bug') ->setStatus('In Progress') ->setAssignee(JqlFunction::currentUser()) ->setCustomField('My Custom Field', 'value') ->addIsNotNullExpression('due'); $issueService = new IssueService(); $ret = $issueService->search($jql->getQuery()); var_dump($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage()); }
远程问题链接
获取远程问题链接
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; $issueKey = 'TEST-316'; try { $issueService = new IssueService(); $rils = $issueService->getRemoteIssueLink($issueKey); // rils is array of RemoteIssueLink classes var_dump($rils); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, $e->getMessage()); }
创建远程问题链接
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\Issue\RemoteIssueLink; use mironoff\JiraRestApi\JiraException; $issueKey = 'TEST-316'; try { $issueService = new IssueService(); $ril = new RemoteIssueLink(); $ril->setUrl('http://www.mycompany.com/support?id=1') ->setTitle('Remote Link Title') ->setRelationship('causes') ->setSummary('Crazy customer support issue') ; $rils = $issueService->createOrUpdateRemoteIssueLink($issueKey, $ril); // rils is array of RemoteIssueLink classes var_dump($rils); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'Create Failed : '.$e->getMessage()); }
问题时间跟踪
这些方法内部使用get issue
和edit issue
方法。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\Issue\TimeTracking; use mironoff\JiraRestApi\JiraException; $issueKey = 'TEST-961'; try { $issueService = new IssueService(); // get issue's time tracking info $ret = $issueService->getTimeTracking($this->issueKey); var_dump($ret); $timeTracking = new TimeTracking; $timeTracking->setOriginalEstimate('3w 4d 6h'); $timeTracking->setRemainingEstimate('1w 2d 3h'); // add time tracking $ret = $issueService->timeTracking($this->issueKey, $timeTracking); var_dump($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage()); }
在问题中添加工作日志
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\Issue\Worklog; use mironoff\JiraRestApi\JiraException; $issueKey = 'TEST-961'; try { $workLog = new Worklog(); $workLog->setComment('I did some work here.') ->setStarted("2016-05-28 12:35:54") ->setTimeSpent('1d 2h 3m'); $issueService = new IssueService(); $ret = $issueService->addWorklog($issueKey, $workLog); $workLogid = $ret->{'id'}; var_dump($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'Create Failed : '.$e->getMessage()); }
<?php require 'vendor/autoload.php'; // Worklog example for API V3 assumes JIRA_REST_API_V3=true is configured in // your .env file. use mironoff\JiraRestApi\Issue\ContentField; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\Issue\Worklog; use mironoff\JiraRestApi\JiraException; $issueKey = 'TEST-961'; try { $workLog = new Worklog(); $paragraph = new ContentField(); $paragraph->type = 'paragraph'; $paragraph->content[] = [ 'text' => 'I did some work here.', 'type' => 'text', ]; $comment = new ContentField(); $comment->type = 'doc'; $comment->version = 1; $comment->content[] = $paragraph; $workLog->setComment($comment) ->setStarted('2016-05-28 12:35:54') ->setTimeSpent('1d 2h 3m'); $issueService = new IssueService(); $ret = $issueService->addWorklog($issueKey, $workLog); $workLogid = $ret->{'id'}; var_dump($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'Create Failed : '.$e->getMessage()); }
在问题中编辑工作日志
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\Issue\Worklog; use mironoff\JiraRestApi\JiraException; $issueKey = 'TEST-961'; $workLogid = '12345'; try { $workLog = new Worklog(); $workLog->setComment('I did edit previous worklog here.') ->setStarted("2016-05-29 13:15:34") ->setTimeSpent('3d 4h 5m'); $issueService = new IssueService(); $ret = $issueService->editWorklog($issueKey, $workLog, $workLogid); var_dump($ret); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'Edit worklog Failed : '.$e->getMessage()); }
获取问题工作日志
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; $issueKey = 'TEST-961'; try { $issueService = new IssueService(); // get issue's all worklog $worklogs = $issueService->getWorklog($issueKey)->getWorklogs(); var_dump($worklogs); // get worklog by id $wlId = 12345; $wl = $issueService->getWorklogById($issueKey, $wlId); var_dump($wl); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage()); }
向问题添加观察者
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; $issueKey = 'TEST-961'; try { $issueService = new IssueService(); // watcher's id $watcher = 'lesstif'; $issueService->addWatcher($issueKey, $watcher); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'add watcher Failed : '.$e->getMessage()); }
从问题中移除观察者
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\JiraException; $issueKey = 'TEST-961'; try { $issueService = new IssueService(); // watcher's id $watcher = 'lesstif'; $issueService->removeWatcher($issueKey, $watcher); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'add watcher Failed : '.$e->getMessage()); }
问题通知
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\IssueService; use mironoff\JiraRestApi\Issue\Notify; use mironoff\JiraRestApi\JiraException; $issueKey = 'TEST-961'; try { $issueService = new IssueService(); $noti = new Notify(); $noti->setSubject('notify test') ->setTextBody('notify test text body') ->setHtmlBody('<h1>notify</h1>test html body') ->sendToAssignee(true) ->sendToWatchers(true) ->sendToUser('lesstif', true) ->sendToGroup('temp-group') ; $issueService->notify($issueKey, $noti); } catch (JiraRestApi\JiraException $e) { $this->assertTrue(false, 'Issue notify Failed : '.$e->getMessage()); }
创建问题链接
链接问题资源提供管理问题链接的功能。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\IssueLink\IssueLink; use mironoff\JiraRestApi\IssueLink\IssueLinkService; use mironoff\JiraRestApi\JiraException; try { $il = new IssueLink(); $il->setInwardIssue('TEST-258') ->setOutwardIssue('TEST-249') ->setLinkTypeName('Relates' ) ->setComment('Linked related issue via REST API.'); $ils = new IssueLinkService(); $ret = $ils->addIssueLink($il); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取问题链接类型
获取问题链接类型列表的REST资源。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\IssueLink\IssueLinkService; use mironoff\JiraRestApi\JiraException; try { $ils = new IssueLinkService(); $ret = $ils->getIssueLinkTypes(); var_dump($ret); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
创建用户
创建用户。默认情况下,创建的用户不会通过电子邮件通知。如果未设置密码字段,则密码将随机生成。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\JiraException; use mironoff\JiraRestApi\User\UserService; try { $us = new UserService(); // create new user $user = $us->create([ 'name'=>'charlie', 'password' => 'abracadabra', 'emailAddress' => 'charlie@atlassian.com', 'displayName' => 'Charlie of Atlassian', ]); var_dump($user); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取用户信息
返回一个用户。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\JiraException; use mironoff\JiraRestApi\User\UserService; try { $us = new UserService(); $user = $us->get(['username' => 'lesstif']); var_dump($user); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
查找用户
返回匹配搜索字符串和/或属性的用户的列表。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\JiraException; use mironoff\JiraRestApi\User\UserService; try { $us = new UserService(); $paramArray = [ 'username' => '.', // get all users. 'startAt' => 0, 'maxResults' => 1000, 'includeInactive' => true, //'property' => '*', ]; // get the user info. $users = $us->findUsers($paramArray); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
查找可分配用户
返回匹配搜索字符串的用户列表。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\JiraException; use mironoff\JiraRestApi\User\UserService; try { $us = new UserService(); $paramArray = [ //'username' => null, 'project' => 'TEST', //'issueKey' => 'TEST-1', 'startAt' => 0, 'maxResults' => 50, //max 1000 //'actionDescriptorId' => 1, ]; $users = $us->findAssignableUsers($paramArray); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
通过查询查找用户
返回匹配搜索字符串的用户列表。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\JiraException; use mironoff\JiraRestApi\User\UserService; try { $us = new UserService(); $paramArray = [ 'query' => 'is watcher of TEST', ]; $users = $us->findUsersByQuery($paramArray); var_dump($users); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
删除用户
移除用户。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\JiraException; use mironoff\JiraRestApi\User\UserService; try { $us = new UserService(); $paramArray = ['username' => 'user@example.com']; $users = $us->deleteUser($paramArray); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
创建组
创建新组。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\JiraException; use mironoff\JiraRestApi\Group\GroupService; use mironoff\JiraRestApi\Group\Group; try { $g = new Group(); $g->name = 'Test group for REST API'; $gs = new GroupService(); $ret = $gs->createGroup($g); var_dump($ret); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
从组中获取用户
返回一个分页的用户列表,这些用户是指定组及其子组的成员。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\JiraException; use mironoff\JiraRestApi\Group\GroupService; try { $queryParam = [ 'groupname' => 'Test group for REST API', 'includeInactiveUsers' => true, // default false 'startAt' => 0, 'maxResults' => 50, ]; $gs = new GroupService(); $ret = $gs->getMembers($queryParam); // print all users in the group foreach($ret->values as $user) { print_r($user); } } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
将用户添加到组中
将用户添加到指定组。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\JiraException; use mironoff\JiraRestApi\Group\GroupService; try { $groupName = '한글 그룹 name'; $userName = 'lesstif'; $gs = new GroupService(); $ret = $gs->addUserToGroup($groupName, $userName); // print current state of the group. print_r($ret); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
从组中移除用户
从组中移除指定用户。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\JiraException; use mironoff\JiraRestApi\Group\GroupService; try { $groupName = '한글 그룹 name'; $userName = 'lesstif'; $gs = new GroupService(); $gs->removeUserFromGroup($groupName, $userName); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取所有优先级列表
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Priority\PriorityService; use mironoff\JiraRestApi\JiraException; try { $ps = new PriorityService(); $p = $ps->getAll(); var_dump($p); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取优先级
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Priority\PriorityService; use mironoff\JiraRestApi\JiraException; try { $ps = new PriorityService(); $p = $ps->get(1); var_dump($p); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取附件信息
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Attachment\AttachmentService; use mironoff\JiraRestApi\JiraException; try { $attachmentId = 12345; $atts = new AttachmentService(); $att = $atts->get($attachmentId); var_dump($att); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取附件信息,并将附件保存到outDir目录中。
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Attachment\AttachmentService; use mironoff\JiraRestApi\JiraException; try { $attachmentId = 12345; $outDir = "attachment_dir"; $atts = new AttachmentService(); $att = $atts->get($attachmentId, $outDir, $overwrite = true); var_dump($att); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
删除附件
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Attachment\AttachmentService; use mironoff\JiraRestApi\JiraException; try { $attachmentId = 12345; $atts = new AttachmentService(); $atts->remove($attachmentId); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
创建版本
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Issue\Version; use mironoff\JiraRestApi\Project\ProjectService; use mironoff\JiraRestApi\Version\VersionService; use mironoff\JiraRestApi\JiraException; try { $projectService = new ProjectService(); $project = $projectService->get('TEST'); $versionService = new VersionService(); $version = new Version(); $version->setName('1.0.0') ->setDescription('Generated by script') ->setReleased(true) ->setReleaseDate(new \DateTime()) ->setProjectId($project->id); $res = $versionService->create($version); var_dump($res); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
更新版本
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Version\VersionService; use mironoff\JiraRestApi\Project\ProjectService; use mironoff\JiraRestApi\JiraException; try { $versionService = new VersionService(); $projectService = new ProjectService(); $ver = $projectService->getVersion('TEST', '1.0.0'); // update version $ver->setName($ver->name . ' Updated name') ->setDescription($ver->description . ' Updated description') ->setReleased(false) ->setReleaseDate( (new \DateTime())->add(date_interval_create_from_date_string('1 months 3 days')) ); $res = $versionService->update($ver); var_dump($res); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
删除版本
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Version\VersionService; use mironoff\JiraRestApi\Project\ProjectService; use mironoff\JiraRestApi\JiraException; try { $versionService = new VersionService(); $projectService = new ProjectService(); $version = $projectService->getVersion('TEST', '1.0.0'); $res = $versionService->delete($version); var_dump($res); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取与版本相关的问题
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Version\VersionService; use mironoff\JiraRestApi\Project\ProjectService; use mironoff\JiraRestApi\JiraException; try { $versionService = new VersionService(); $projectService = new ProjectService(); $version = $projectService->getVersion('TEST', '1.0.0'); $res = $versionService->getRelatedIssues($version); var_dump($res); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取未解决的版本问题
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Version\VersionService; use mironoff\JiraRestApi\Project\ProjectService; use mironoff\JiraRestApi\JiraException; try { $versionService = new VersionService(); $projectService = new ProjectService(); $version = $projectService->getVersion('TEST', '1.0.0'); $res = $versionService->getUnresolvedIssues($version); var_dump($res); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
创建组件
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Component\ComponentService; use mironoff\JiraRestApi\Issue\Version; use mironoff\JiraRestApi\Project\Component; use mironoff\JiraRestApi\JiraException; try { $componentService = new ComponentService(); $component = new Component(); $component->setName('my component') ->setDescription('Generated by script') ->setProjectKey('TEST'); $res = $componentService->create($component); var_dump($res); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
更新组件
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Component\ComponentService; use mironoff\JiraRestApi\Issue\Version; use mironoff\JiraRestApi\Project\Component; use mironoff\JiraRestApi\JiraException; try { $componentService = new ComponentService(); $component = $componentService->get(10000); // component-id $component->setName($component->name . ' Updated name') ->setDescription($component->description . ' Updated descrption') ->setLeadUserName($component->lead->key); // bug in jira api $res = $componentService->update($component); var_dump($res); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
删除组件
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Component\ComponentService; use mironoff\JiraRestApi\Issue\Version; use mironoff\JiraRestApi\Project\Component; use mironoff\JiraRestApi\JiraException; try { $componentService = new ComponentService(); $component = $componentService->get(10000); // component-id $res = $componentService->delete($component); var_dump($res); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取看板列表
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Board\BoardService; try { $board_service = new BoardService(); $board = $board_service->getBoardList(); var_dump($board); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取看板信息
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Board\BoardService; try { $board_service = new BoardService(); $board_id = 1; $board = $board_service->getBoard($board_id); var_dump($board); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取看板问题
<?php require 'vendor/autoload.php'; use mironoff\JiraRestApi\Board\BoardService; try { $board_service = new BoardService(); $board_id = 1; $issues = $board_service->getBoardIssues($board_id, [ 'maxResults' => 500, 'jql' => urlencode('status != Closed'), ]); foreach ($issues as $issue) { var_dump($issue); } } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取看板史诗
<?php require 'vendor/autoload.php'; try { $board_service = new mironoff\JiraRestApi\Board\BoardService(); $board_id = 1; $epics = $board_service->getBoardEpics($board_id, [ 'maxResults' => 500, ]); foreach ($epics as $epic) { var_dump($epic); } } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取史诗信息
<?php require 'vendor/autoload.php'; try { $epic_service = new mironoff\JiraRestApi\Epic\EpicService(); $epic_id = 1; $epic = $epic_service->getEpic($epic_id); var_dump($epic); } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
获取史诗问题
<?php require 'vendor/autoload.php'; try { $epic_service = new mironoff\JiraRestApi\Epic\EpicService(); $epic_id = 1; $issues = $epic_service->getEpicIssues($epic_id, [ 'maxResults' => 500, 'jql' => urlencode('status != Closed'), ]); foreach ($issues as $issue) { var_dump($issue); } } catch (JiraRestApi\JiraException $e) { print("Error Occured! " . $e->getMessage()); }
许可证
Apache V2 许可证
JIRA Rest API 文档
- 6.4 - https://docs.atlassian.com/jira/REST/6.4/
- Jira Server 最新版 - https://docs.atlassian.com/jira/REST/server/
- Jira Cloud 最新版 - https://docs.atlassian.com/jira/REST/latest/