Get My Daily Jira Worklog
At work I’m currently evaluating Jira as our “Scrum Tool”. Currently we work with various tools:
- Physical Taskboard
- TestTrack Pro
- Excel Sheets
- Timetracking Tool
to assist our scrum process. As a java develepors I endeavore to reuse source code and encapsulate responsibilities within components with precisely defined interfaces. In my daily work I have to manage 4 tools and keep all the information synchronized, so I gave Jira a try to replace some of the current tools.
I am currently evaluating Jira in the running sprint, and so far it seems to manage all our requirements. But there is information I couldn’t get out of Jira: My Daily Worklog. I need the daily worklog to generate productivity reports and to invoice our customer.
I haven’t found such a report in the Jira Plugin list, so i wrote a small java application to get this done by utilizing the Jira SOAP web-service:
JiraSoapServiceService jiraSoapServiceGetter = new JiraSoapServiceServiceLocator();
JiraSoapService soap = jiraSoapServiceGetter
.getJirasoapserviceV2(
new URL("http://url.to.jira/rpc/soap/jirasoapservice-v2?wsdl"));
String token = soap.login("myUsername", "mySecret");
RemoteIssue[] issuesFromTextSearch = soap
.getIssuesFromJqlSearch(
token,
"project = MYPROJECT AND assignee = myUsername AND fixVersion = 'Sprint 46'",
10000);
List<WorklogEntry> entries = new ArrayList<WorklogEntry>();
for (RemoteIssue remoteIssue : issuesFromTextSearch) {
RemoteWorklog[] worklogs = soap.getWorklogs(token, remoteIssue.getKey());
for (RemoteWorklog remoteWorklog : worklogs) {
entries.add(new WorklogEntry(
remoteWorklog.getCreated().getTime(),
remoteWorklog.getTimeSpent(),
remoteIssue.getKey(),
remoteIssue.getSummary()));
}
}
DateTime today = new DateTime();
for (WorklogEntry worklogEntry : entries) {
DateTime worklogDateTime = new DateTime(worklogEntry.getCreated());
if (worklogDateTime.getDayOfYear() == today.getDayOfYear()
&& worklogDateTime.getYear() == today.getYear()) {
System.out.println(
worklogEntry.getIssueKey() +" - "
+ worklogEntry.getIssueDescription()
+ " - "+ worklogEntry.getTimeSpent());
}
}
This is a quick hack and far away from any clean code. Maybe I’ll write a cusomt Jira Report in my spare time to get the above data out of Jira in the future.