Class: Fastlane::Actions::DingTalkMsgPushAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



39
40
41
# File 'lib/fastlane/plugin/ding_talk_msg_push/actions/ding_talk_msg_push_action.rb', line 39

def self.authors
  ["lingyou"]
end

.available_optionsObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fastlane/plugin/ding_talk_msg_push/actions/ding_talk_msg_push_action.rb', line 52

def self.available_options
  [
     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



35
36
37
# File 'lib/fastlane/plugin/ding_talk_msg_push/actions/ding_talk_msg_push_action.rb', line 35

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

.detailsObject



47
48
49
50
# File 'lib/fastlane/plugin/ding_talk_msg_push/actions/ding_talk_msg_push_action.rb', line 47

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
75
76
77
78
# File 'lib/fastlane/plugin/ding_talk_msg_push/actions/ding_talk_msg_push_action.rb', line 72

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



43
44
45
# File 'lib/fastlane/plugin/ding_talk_msg_push/actions/ding_talk_msg_push_action.rb', line 43

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
# File 'lib/fastlane/plugin/ding_talk_msg_push/actions/ding_talk_msg_push_action.rb', line 7

def self.run(params)
  UI.message("The ding_talk_msg_push plugin is working!")
  # UI.message(params.to_json)
  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": "text", 
        "text": {
            "content": "#{text}",
         },
         "at": {
            "isAtAll": #{at_all}
        }
      }'
  }
  UI.message(curl)
  system curl
end