Class: Fastlane::Actions::DingTalkMsgMdPushAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



41
42
43
# File 'lib/fastlane/plugin/ding_talk_msg_push/actions/ding_talk_msg_md_push_action.rb', line 41

def self.authors
  ["lingyou"]
end

.available_optionsObject



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

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :title,
      env_name: "DING_TALK_MSG_PUSH_TITLE",
   description: "the dingtalk msg title",
      optional: false,
          type: String),
     FastlaneCore::ConfigItem.new(key: :token,
                             env_name: "DING_TALK_MSG_PUSH_TOKEN",
                          description: "the dingtalk robot token",
                             optional: false,
                                 type: String),
     FastlaneCore::ConfigItem.new(key: :text,
                                  env_name: "DING_TALK_MSG_PUSH_TEXT",
                               description: "the content text send",
                                  optional: false,
                                      type: String),
     FastlaneCore::ConfigItem.new(key: :at_all,
                                        env_name: "DING_TALK_MSG_PUSH_AT_ALL",
                                     description: "at all user",
                                       is_string: false,
                                   default_value: false)
  ]
end

.descriptionObject



37
38
39
# File 'lib/fastlane/plugin/ding_talk_msg_push/actions/ding_talk_msg_md_push_action.rb', line 37

def self.description
  "dingTalk robot msg push tool"
end

.detailsObject



49
50
51
52
# File 'lib/fastlane/plugin/ding_talk_msg_push/actions/ding_talk_msg_md_push_action.rb', line 49

def self.details
  # Optional:
  "钉钉推送工具"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


79
80
81
82
83
84
85
# File 'lib/fastlane/plugin/ding_talk_msg_push/actions/ding_talk_msg_md_push_action.rb', line 79

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



45
46
47
# File 'lib/fastlane/plugin/ding_talk_msg_push/actions/ding_talk_msg_md_push_action.rb', line 45

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

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fastlane/plugin/ding_talk_msg_push/actions/ding_talk_msg_md_push_action.rb', line 7

def self.run(params)
  UI.message("The ding_talk_msg_push plugin is working!")
  # UI.message(params.to_json)
  title = params[:title] || ''
  token = params[:token]
  text = params[:text]
  at_all = params[:at_all] == nil ? false : params[:at_all]
  
  curl = %Q{
    curl 'https://oapi.dingtalk.com/robot/send?access_token=#{token}' \
       -H 'Content-Type: application/json' \
       -d ' {
              "msgtype": "markdown",
              "markdown": {
                  "title": "#{title}",
                  "text": "#{text}"
              },
              "at": {
                  "isAtAll": #{at_all}
              }
          }'
    }
  UI.message(curl)
  system curl
end