JiraRestApi\Issue\IssueService::transition PHP Метод

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

Perform a transition on an issue.
public transition ( $issueIdOrKey, $transition ) : nothing
Результат nothing - if transition was successful return http 204(no contents)
    public function transition($issueIdOrKey, $transition)
    {
        $this->log->addDebug('transition=' . var_export($transition, true));
        if (!isset($transition->transition['id'])) {
            $transition->transition['id'] = $this->findTransitonId($issueIdOrKey, $transition->transition['name']);
        }
        $data = json_encode($transition);
        $this->log->addDebug("transition req={$data}\n");
        $ret = $this->exec($this->uri . "/{$issueIdOrKey}/transitions", $data, 'POST');
        $this->log->addDebug('getTransitions result=' . var_export($ret, true));
    }

Usage Example

Пример #1
0
function processPushHook($app)
{
    $json = $app->request->getBody();
    $hook = json_decode($json, true);
    $app->log->debug('processPushHook : ' . json_encode($hook, JSON_PRETTY_PRINT));
    $u = getGitUserName(2, $app);
    foreach ($hook['commits'] as $commit) {
        $app->log->info('Commit : ' . json_encode($commit, JSON_PRETTY_PRINT));
        $issueKey = extractIssueKey($commit['message']);
        if (empty($issueKey)) {
            continue;
        }
        $transitionName = needTransition($commit['message'], $message);
        try {
            if (empty($transitionName)) {
                $comment = new Comment();
                $body = sprintf($message, $u->username, $commit['url']);
                $comment->setBody($body);
                $issueService = new IssueService();
                $ret = $issueService->addComment($issueKey, $comment);
            } else {
                $transition = new Transition();
                $transition->setTransitionName($transitionName);
                $body = sprintf($message, $u->username, $transitionName, $commit['url']);
                $transition->setCommentBody($body);
                $issueService = new IssueService();
                $issueService->transition($issueKey, $transition);
            }
        } catch (JIRAException $e) {
            $app->log->error("add Comment Failed : " . $e->getMessage());
        }
    }
    $app->response->setStatus(200);
}
All Usage Examples Of JiraRestApi\Issue\IssueService::transition