Top Level Namespace
Instance Method Summary collapse
- #create_ticket(type, summary, description, user, group, component, reviewboard = nil, git_repo = nil, branch = nil) ⇒ Object
- #init ⇒ Object
- #input(prompt, key, default = nil, &validation) ⇒ Object
- #login ⇒ Object
- #password ⇒ Object
- #save ⇒ Object
Instance Method Details
#create_ticket(type, summary, description, user, group, component, reviewboard = nil, git_repo = nil, branch = nil) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'bin/jira', line 50 def create_ticket(type, summary, description, user, group, component, reviewboard = nil, git_repo = nil, branch = nil) issue = Jira4R::V2::RemoteIssue.new issue.summary = summary issue.description = description issue.type = type issue.assignee = user issue.reporter = user issue.project = group issue.components = $jira.getComponents(group).select{|c| c.name == component } issue.customFieldValues = [] if reviewboard # reviewboard custom field rb = Jira4R::V2::RemoteCustomFieldValue.new rb.customfieldId = "customfield_10000" rb.values = reviewboard issue.customFieldValues << rb end if branch # branch custom field b = Jira4R::V2::RemoteCustomFieldValue.new b.customfieldId = "customfield_10022" b.values = branch issue.customFieldValues << b end if git_repo # 'git repository' custom field gr = Jira4R::V2::RemoteCustomFieldValue.new gr.customfieldId = "customfield_10052" gr.values = git_repo issue.customFieldValues << gr end puts issue.inspect issue = $jira.createIssue(issue) rescue SOAP::FaultError => e if e. =~ /auth/ password retry else raise end end |
#init ⇒ Object
38 39 40 41 42 43 |
# File 'bin/jira', line 38 def init $jira = Jira4R::JiraTool.new(2, $config["location"]) logger = Logger.new(STDERR) logger.level = Logger::WARN $jira.logger = logger end |
#input(prompt, key, default = nil, &validation) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'bin/jira', line 11 def input(prompt, key, default = nil, &validation) key = key.to_s @original = $config[key] input = ask("#{prompt} [#{$config[key] || default}]") $config[key] = input unless input.empty? $config[key] ||= default validation.call if validation save $config rescue $config[key] = @original raise end |
#login ⇒ Object
45 46 47 48 |
# File 'bin/jira', line 45 def login init $jira.instance_variable_set("@token", $config["token"]) end |
#password ⇒ Object
30 31 32 33 34 35 36 |
# File 'bin/jira', line 30 def password password = ask("Enter password: ") { |q| q.echo = false } init $config["token"] = $jira.login($config["user"], password) save login end |
#save ⇒ Object
24 25 26 27 28 |
# File 'bin/jira', line 24 def save File.open($config_file, "w") do |f| YAML.dump($config, f) end end |