Created
July 26, 2016 21:05
-
-
Save cemeyer2/26cbc60f97a293fef01c7aaf3e36b149 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'jira' | |
require 'chronic' | |
require_relative 'credz' #file that defines USERNAME and PASSWORD | |
def jira_client | |
jira_options = { | |
:username => USERNAME, | |
:password => PASSWORD, | |
:site => 'https://jira.homeawaycorp.com', | |
:context_path => '', | |
:auth_type => :basic | |
} | |
JIRA::Client.new(jira_options) | |
end | |
ticket = 'COREAPI-10411' #your ticket for loging hours | |
issue = jira_client.Issue.find(ticket) | |
(1..31).each do |day| | |
parsed = Chronic.parse("July #{day} 2016") | |
day_of_week = parsed.wday | |
next if day_of_week == 0 || day_of_week == 6 #skip weekends | |
attrs = { | |
'author' => { | |
'name' => USERNAME | |
}, | |
'timeSpent' => '8h', | |
'started' => parsed.strftime('%Y-%m-%dT00:00:00.000-0500') | |
} | |
worklog = issue.worklogs.build | |
worklog.save!(attrs) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment