Wednesday, November 13, 2019

Log time on JIRA with REST API

If you get the chance to work with people that want you to log everything you do on jira, this little script can help:

#!/bin/bash

user="user"
password="password"

# $1 : jira number
# $2 : log to echo
# $3 : time
# $4 : jira log comment
logTime () {
  echo "#######################################"
  echo "Logging $2"
  echo "#######################################"
  
  curl -k --request POST \
    --url "https://jira.toto.fr/rest/api/2/issue/$1/worklog" \
    --user "$user:$password" \
    --header 'Accept: application/json' \
    --header 'Content-Type: application/json' \
    --data '{
      "comment": "'"$4"'",
      "timeSpent": "'"$3"'"
    }'
}

logTime "Jira-number" "log jira" "time (format : 15m, 4h 3d ...)" "jira comment"
logTime ...
logTime ...


No comments:

Post a Comment