Class: Fastlane::Actions::DingtalkRobotAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/dingtalk_robot/actions/dingtalk_robot_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



43
44
45
# File 'lib/fastlane/plugin/dingtalk_robot/actions/dingtalk_robot_action.rb', line 43

def self.authors
  ["InfiniteReverse"]
end

.available_optionsObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/fastlane/plugin/dingtalk_robot/actions/dingtalk_robot_action.rb', line 56

def self.available_options
  [
      FastlaneCore::ConfigItem.new(key: :access_token,
                                   env_name: "DINGTALK_ROBOT_ACCESS_TOKEN",
                                   description: "access token for dingtalk robot webhook",
                                   optional: false,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :title,
                                   env_name: "DINGTALK_ROBOT_TITLE",
                                   description: "title for dingtalk robot",
                                   optional: false,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :markdown,
                                   env_name: "DINGTALK_ROBOT_MARKDOWN",
                                   description: "content for dingtalk robot",
                                   optional: false,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :at_mobiles,
                                   env_name: "DINGTALK_ROBOT_AT_MOBILES",
                                   description: "@ list of msg for dingtalk robot",
                                   optional: true,
                                   type: Array)
  ]
end

.descriptionObject



39
40
41
# File 'lib/fastlane/plugin/dingtalk_robot/actions/dingtalk_robot_action.rb', line 39

def self.description
  "webhook for dingtalk robot"
end

.detailsObject



51
52
53
54
# File 'lib/fastlane/plugin/dingtalk_robot/actions/dingtalk_robot_action.rb', line 51

def self.details
  # Optional:
  "webhook for dingtalk robot"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


81
82
83
84
85
86
87
# File 'lib/fastlane/plugin/dingtalk_robot/actions/dingtalk_robot_action.rb', line 81

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



47
48
49
# File 'lib/fastlane/plugin/dingtalk_robot/actions/dingtalk_robot_action.rb', line 47

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fastlane/plugin/dingtalk_robot/actions/dingtalk_robot_action.rb', line 8

def self.run(params)
  UI.message("The dingtalk_robot plugin is working!")

  access_token = params[:access_token]
  title = params[:title]
  content = params[:markdown]
  at_mobiles = params[:at_mobiles]

  send_markdown_at_one(access_token, title, content, at_mobiles)

end

.send_markdown_at_one(access_token, title, content, at_mobiles) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fastlane/plugin/dingtalk_robot/actions/dingtalk_robot_action.rb', line 20

def self.send_markdown_at_one(access_token, title, content, at_mobiles)

  DingBot.endpoint='https://oapi.dingtalk.com/robot/send'
  DingBot.access_token = access_token

  text = content + "\n"
  at_mobiles.each do |mobile|
    text << '@' + mobile.to_s
  end

  message = DingBot::Message::Markdown.new(
      title,
      text,
      at_mobiles,
      false
  )
  DingBot.send_msg(message)
end