Skip to content

Instantly share code, notes, and snippets.

@edwinclement08
Forked from iansltx/jtt.php
Created April 29, 2021 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edwinclement08/727ab7f3f39c202bac5b3a33e346306c to your computer and use it in GitHub Desktop.
Save edwinclement08/727ab7f3f39c202bac5b3a33e346306c to your computer and use it in GitHub Desktop.
Quick CLI for adding work log times in JIRA
#!/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)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment