Skip to content

Instantly share code, notes, and snippets.

@AlphaGit
Last active November 5, 2017 17:13
Show Gist options
  • Save AlphaGit/1ea8316e6f585ba42a73d8b4444a148d to your computer and use it in GitHub Desktop.
Save AlphaGit/1ea8316e6f585ba42a73d8b4444a148d to your computer and use it in GitHub Desktop.
Executing worklogger
# log hours to destination systems each day at noon
0 12 * * * /home/myUser/scripts/log-daily-hours.sh
# generate monthly report of worklogs each month, 1st day at 8 AM
0 8 1 * * /home/myUser/scripts/log-monthly-hours.sh
{
"log4js": {
"appenders": {
"outAppender": {
"type": "stdout",
"layout": {
"type": "pattern",
"pattern": "[%d{ABSOLUTE}] [%-5p] %m"
}
}
},
"categories": {
"default": {
"appenders": ["outAppender"],
"level": "info"
}
}
},
"options": {
"minimumLoggableTimeSlotInMinutes": 30,
"timePeriod": {
"begin": {
"fromNow": "last",
"unit": "day"
},
"end": {
"fromNow": "this",
"unit": "day"
}
}
},
"inputs": [{
"type": "GoogleCalendar",
"name": "My Google Calendar",
"calendars": [{
"id": "[myCalendarIdForClient1]@group.calendar.google.com",
"includeTags": [
"client:[Client1]",
"project:[Project1]",
"HarvestProject:[Project1]",
"HarvestTask:[Task1]"
]
}, {
"id": "[myCalendarIdForClient2]@group.calendar.google.com",
"includeTags": [
"client:[Client2]",
"project:[Project2]",
"HarvestProject:[Project2]",
"HarvestTask:[Task2]"
]
}]
}],
"transformations": [{
"action": {
"type": "addTags",
"tagsToAdd": [
{ "name": "JiraTicket", "extractCaptureFromSummary": "\\[([^\\[\\]]+)\\]" }
]
}
}],
"outputs": [{
"type": "HarvestApp",
"accountId": "[myHarvestAccountId]",
"token": "[myHarvestAppApiToken]",
"contactInformation": "[myPersonalEmail]@gmail.com",
"selectProjectFromTag": "HarvestProject",
"selectTaskFromTag": "HarvestTask"
}, {
"condition": {
"type": "hasTag",
"tagName": "client",
"tagValue": "[Client1]"
},
"type": "JiraWorklog",
"JiraUrl": "https://myClientJira.atlassian.net",
"JiraUsername": "[myJiraUsername]",
"JiraPassword": "[myJiraPassword]"
}, {
"type": "Logger"
}]
}
#!/bin/bash
pushd /home/myUser/scripts/worklogger/
export PATH="$PATH:/home/myUser/.nvm/versions/node/v8.7.0/bin"
node start.js -c _private/daily_configuration.json
popd
#!/bin/bash
pushd /home/myUser/scripts/worklogger/
export PATH="$PATH:/home/myUser/.nvm/versions/node/v8.7.0/bin"
node start.js -c _private/monthly_configuration.json
popd
{
"log4js": {
"appenders": {
"outAppender": {
"type": "stdout",
"layout": {
"type": "pattern",
"pattern": "[%d{ABSOLUTE}] [%-5p] %m"
}
}
},
"categories": {
"default": {
"appenders": ["outAppender"],
"level": "info"
}
}
},
"options": {
"minimumLoggableTimeSlotInMinutes": 30,
"timePeriod": {
"begin": {
"fromNow": "last",
"unit": "month"
},
"end": {
"fromNow": "this",
"unit": "month"
}
}
},
"inputs": [{
"type": "GoogleCalendar",
"name": "My Google Calendar",
"calendars": [{
"id": "[myCalendarIdForClient1]@group.calendar.google.com",
"includeTags": [
"client:[Client1]",
"project:[Project1]"
]
}, {
"id": "[myCalendarIdForClient2]@group.calendar.google.com",
"includeTags": [
"client:[Client2]",
"project:[Project2]"
]
}]
}],
"transformations": [{
"action": {
"type": "addTags",
"tagsToAdd": [
{ "name": "JiraTicket", "extractCaptureFromSummary": "\\[([^\\[\\]]+)\\]" }
]
}
}],
"outputs": [{
"type": "Logger"
}, {
"type": "TextFile",
"filePath": "monthly-hours-summary.txt",
"formatter": {
"type": "SummaryTextFileFormatter",
"aggregateByTags": [
["client", "project"],
["JiraTicket"]
]
}
}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment