Class: Fastlane::Actions::DingTalkAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::DingTalkAction
- Defined in:
- lib/fastlane/plugin/ding_talk/actions/ding_talk_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
71 72 73 |
# File 'lib/fastlane/plugin/ding_talk/actions/ding_talk_action.rb', line 71 def self. ["gaoxiang"] end |
.available_options ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/fastlane/plugin/ding_talk/actions/ding_talk_action.rb', line 84 def self. [ FastlaneCore::ConfigItem.new(key: :api_key, env_name: "PGYER_API_KEY", description: "api_key in your pgyer account", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :app_key, env_name: "PGYER_APP_KEY", description: "app_key for your app", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :access_token, env_name: "DING_TALK_ROBOT_ACCESS_TOKEN", description: "access_token for your ding talk robot", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :markdown_desc, env_name: "DING_TALK_APP_DESCRIPTION", description: "description for your app", optional: true, type: String) ] end |
.description ⇒ Object
67 68 69 |
# File 'lib/fastlane/plugin/ding_talk/actions/ding_talk_action.rb', line 67 def self.description "Send the packaging information to the ding talk." end |
.details ⇒ Object
79 80 81 82 |
# File 'lib/fastlane/plugin/ding_talk/actions/ding_talk_action.rb', line 79 def self.details # Optional: "Send the packaging information to the ding talk, and provide the qr code for others to install." end |
.is_supported?(platform) ⇒ Boolean
109 110 111 112 113 114 115 |
# File 'lib/fastlane/plugin/ding_talk/actions/ding_talk_action.rb', line 109 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_value ⇒ Object
75 76 77 |
# File 'lib/fastlane/plugin/ding_talk/actions/ding_talk_action.rb', line 75 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 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 |
# File 'lib/fastlane/plugin/ding_talk/actions/ding_talk_action.rb', line 7 def self.run(params) UI.("The ding_talk plugin is working!") api_key = params[:api_key] app_key = params[:app_key] access_token = params[:access_token] markdown_desc = params[:markdown_desc] params = { '_api_key' => api_key, 'appKey' => app_key } UI.("Start get app information from pgyer...") # 获取App详细信息 response = Net::HTTP.post_form URI('https://www.pgyer.com/apiv2/app/view'), params result = JSON.parse(response.body) status_code = result["code"] = result["message"] if status_code != 0 UI.error('pgyer error message: ' + ) return end UI.success("Successfully get app information!") # 应用二维码地址 buildQRCodeURL = result["data"]["buildQRCodeURL"] # 将应用信息发送到钉钉 uri = URI.parse("https://oapi.dingtalk.com/robot/send?access_token=#{access_token}") https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true req = Net::HTTP::Post.new(uri.request_uri) req.body = { 'msgtype' => 'markdown', 'markdown' => { 'title': 'A new app update from fastlane.', 'text': "#{markdown_desc} <br> " }, 'at': { 'atMobiles': [], 'isAtAll': false } }.to_json req.content_type = 'application/json' resp = https.request(req) json = JSON.parse(resp.body) if json["errcode"] != 0 UI.error('ding talk error message: ' + json["errmsg"]) return end UI.success("Successfully send qr code to ding talk!") end |