Class: Pantograph::Actions::JiraAction

Inherits:
Pantograph::Action show all
Defined in:
pantograph/lib/pantograph/actions/jira.rb

Constant Summary

Constants inherited from Pantograph::Action

Pantograph::Action::AVAILABLE_CATEGORIES, Pantograph::Action::RETURN_TYPES

Documentation collapse

Class Method Summary collapse

Methods inherited from Pantograph::Action

action_name, author, deprecated_notes, details, lane_context, method_missing, other_action, output, return_type, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject



77
78
79
# File 'pantograph/lib/pantograph/actions/jira.rb', line 77

def self.authors
  ['iAmChrisTruman']
end

.available_optionsObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'pantograph/lib/pantograph/actions/jira.rb', line 31

def self.available_options
  [
    PantographCore::ConfigItem.new(
      key: :url,
      env_name: 'JIRA_SITE',
      description: 'URL for Jira instance',
      optional: false
    ),
    PantographCore::ConfigItem.new(
      key: :context_path,
      env_name: 'JIRA_CONTEXT_PATH',
      description: "Appends to the url (ex: \"/jira\")",
      optional: true,
      default_value: ''
    ),
    PantographCore::ConfigItem.new(
      key: :username,
      env_name: 'JIRA_USERNAME',
      description: 'Username for JIRA instance',
      optional: false
    ),
    PantographCore::ConfigItem.new(
      key: :password,
      env_name: 'JIRA_PASSWORD',
      description: 'Password for Jira',
      sensitive: true,
      optional: false
    ),
    PantographCore::ConfigItem.new(
      key: :ticket_id,
      env_name: 'JIRA_TICKET_ID',
      description: 'Ticket ID for Jira, i.e. APP-123',
      optional: false
    ),
    PantographCore::ConfigItem.new(
      key: :comment_text,
      env_name: 'JIRA_COMMENT_TEXT',
      description: 'Text to add to the ticket as a comment',
      optional: false
    )
  ]
end

.categoryObject



105
106
107
# File 'pantograph/lib/pantograph/actions/jira.rb', line 105

def self.category
  :misc
end

.descriptionObject



27
28
29
# File 'pantograph/lib/pantograph/actions/jira.rb', line 27

def self.description
  'Leave a comment on JIRA tickets'
end

.example_codeObject



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'pantograph/lib/pantograph/actions/jira.rb', line 85

def self.example_code
  [
    'jira(
      url: "https://bugs.yourdomain.com",
      username: "Your username",
      password: "Your password",
      ticket_id: "Ticket ID, i.e. APP-123",
      comment_text: "Text to post as a comment"
    )',
    'jira(
      url: "https://yourserverdomain.com",
      context_path: "/jira",
      username: "Your username",
      password: "Your password",
      ticket_id: "Ticket ID, i.e. APP-123",
      comment_text: "Text to post as a comment"
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



81
82
83
# File 'pantograph/lib/pantograph/actions/jira.rb', line 81

def self.is_supported?(platform)
  true
end

.return_valueObject



74
75
# File 'pantograph/lib/pantograph/actions/jira.rb', line 74

def self.return_value
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'pantograph/lib/pantograph/actions/jira.rb', line 4

def self.run(params)
  Actions.verify_gem!('jira-ruby')
  require 'jira-ruby'

  client = JIRA::Client.new(
    {
      site: params[:url],
      context_path: params[:context_path],
      auth_type: :basic,
      username: params[:username],
      password: params[:password]
    }
  )

  issue   = client.Issue.find(params[:ticket_id])
  comment = issue.comments.build
  comment.save({ 'body' => params[:comment_text] })
end