chobie\Jira\Api::addComment PHP Метод

addComment() публичный Метод

Add a comment to a ticket.
public addComment ( string $issue_key, array | string $params ) : Result | false
$issue_key string Issue key should be "YOURPROJ-221".
$params array | string Params.
Результат chobie\Jira\Api\Result | false
    public function addComment($issue_key, $params)
    {
        if (is_string($params)) {
            // If $params is scalar string value -> wrapping it properly.
            $params = array('body' => $params);
        }
        return $this->api(self::REQUEST_POST, sprintf('/rest/api/2/issue/%s/comment', $issue_key), $params);
    }

Usage Example

Пример #1
0
 /**
  * Add a comment in JIRA with the commit hash
  * @param Commit $commit The commit for which we're running the Git Hook
  * @throws GitHookException if requirement fails
  */
 public function run(Commit $commit)
 {
     /** @var \Bart\GitHook\GitHookConfig $hConfigs */
     $hConfigs = Diesel::create('\\Bart\\GitHook\\GitHookConfig', $commit);
     // Apply template to produce desired comment for JIRA issue
     $template = $hConfigs->jiraCommentTemplate();
     $count = preg_match_all('/\\%s/', $template);
     $this->logger->debug("Loaded jira template --{$template}-- and found {$count} token(s)");
     $vsprintf_args = [];
     if ($count !== false) {
         $vsprintf_args = array_fill(0, $count, $commit->revision());
     }
     $comment = vsprintf($template, $vsprintf_args);
     $jiraIssues = $commit->jiras();
     $this->logger->debug('Found ' . count($jiraIssues) . " jira issue(s) in {$commit}");
     foreach ($jiraIssues as $jira) {
         $this->logger->debug("Adding comment to jira {$jira}");
         $this->jiraClient->addComment($jira->id(), $comment);
     }
 }
All Usage Examples Of chobie\Jira\Api::addComment