-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog-youtrack-work.sh
executable file
·34 lines (30 loc) · 1.18 KB
/
log-youtrack-work.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
set -e;
CSV_FILE=$1;
AUTH_TOKEN="set your user token";
YOUTRACK_HOST="https://company.myjetbrains.com";
function logWork {
curl --location --request POST "${YOUTRACK_HOST}/youtrack/rest/issue/${issue}/timetracking/workitem" \
--header "Authorization: Bearer ${AUTH_TOKEN}" \
--header 'Content-Type: application/xml' \
--data-raw "<workItem>
<date>$unix_date</date>
<duration>$duration</duration>
<description>$description</description>
<worktype>
<name>$workitem_type</name>
</worktype>
</workItem>"
}
x=1
while IFS=, read -r date duration issue type description
do
unix_date=$(date "+%s%3N" -d ${date})
duration=$(echo ${duration} | sed 's/"//g')
issue=$(echo ${issue} | sed 's/"//g')
workitem_type=$(echo ${type} | sed 's/"//g')
description=$(echo ${description} | sed 's/"//g')
logWork
echo "Row: '${x}', work logged in issue ${issue} as '${workitem_type}'"
x=$(( $x + 1 ))
done < ${CSV_FILE}