Skip to content

Instantly share code, notes, and snippets.

@gecbla
Forked from iansltx/jtt.php
Created May 16, 2018 17:45
Show Gist options
  • Select an option

  • Save gecbla/35c45669b4308617ee55eeefd0b86cf2 to your computer and use it in GitHub Desktop.

Select an option

Save gecbla/35c45669b4308617ee55eeefd0b86cf2 to your computer and use it in GitHub Desktop.

Revisions

  1. @iansltx iansltx revised this gist Mar 4, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion jtt.php
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    <?php

    if ($argc < 3) {
    die("Usage: ./jtt.php ISSUE-1 30m optional comment here\n");
    die("Usage: ./jtt.php ISSUE-1 30m optional comment here\n");
    }

    $username = 'EMAIL_GOES_HERE';
  2. @iansltx iansltx created this gist Mar 4, 2018.
    22 changes: 22 additions & 0 deletions jtt.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/usr/bin/env php
    <?php

    if ($argc < 3) {
    die("Usage: ./jtt.php ISSUE-1 30m optional comment here\n");
    }

    $username = 'EMAIL_GOES_HERE';
    $token = 'API_KEY_HERE'; // see https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-basic-authentication/
    $team = 'TEAM_NAME_HERE';

    $ch = curl_init('https://' . $team . '.atlassian.net/rest/api/2/issue/' . $argv[1] . '/worklog');
    curl_setopt_array($ch, [
    CURLOPT_HTTPHEADER => [
    'Accept: application/json',
    'Content-Type: application/json',
    ],
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD => $username . ':' . $token,
    CURLOPT_POSTFIELDS => json_encode(['timeSpent' => $argv[2], 'comment' => implode(' ', array_slice($argv, 3))])
    ]);
    print_r(json_decode(curl_exec($ch)));