Sha256: 789f4a93b8c225557d174aff3f9ea3bf39ae097a74e4de03b7933e7f6306b5fd

Contents?: true

Size: 1.75 KB

Versions: 288

Compression:

Stored size: 1.75 KB

Contents

require 'fastlane/action'
require 'fastlane/actions/slack'

require_relative 'module'

module Scan
  class SlackPoster
    def run(results)
      return if Scan.config[:skip_slack]
      return if Scan.config[:slack_only_on_failure] && results[:failures] == 0
      return if Scan.config[:slack_url].to_s.empty?

      if Scan.config[:slack_channel].to_s.length > 0
        channel = Scan.config[:slack_channel]
        channel = ('#' + channel) unless ['#', '@'].include?(channel[0]) # send message to channel by default
      end

      username = Scan.config[:slack_use_webhook_configured_username_and_icon] ? nil : Scan.config[:slack_username]
      icon_url = Scan.config[:slack_use_webhook_configured_username_and_icon] ? nil : Scan.config[:slack_icon_url]
      fields = []

      if results[:build_errors]
        fields << {
          title: 'Build Errors',
          value: results[:build_errors].to_s,
          short: true
        }
      end

      if results[:failures]
        fields << {
          title: 'Test Failures',
          value: results[:failures].to_s,
          short: true
        }
      end

      if results[:tests] && results[:failures]
        fields << {
          title: 'Successful Tests',
          value: (results[:tests] - results[:failures]).to_s,
          short: true
        }
      end

      Fastlane::Actions::SlackAction.run({
        message: "#{Scan.project.app_name} Tests:\n#{Scan.config[:slack_message]}",
        channel: channel,
        slack_url: Scan.config[:slack_url].to_s,
        success: results[:build_errors].to_i == 0 && results[:failures].to_i == 0,
        username: username,
        icon_url: icon_url,
        payload: {},
        attachment_properties: {
          fields: fields
        }
      })
    end
  end
end

Version data entries

288 entries across 288 versions & 2 rubygems

Version Path
fastlane-2.126.0.beta.20190622200100 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190621200104 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190620200055 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190619200046 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190618200051 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190617200114 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190616200045 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190615200013 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190614200105 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190613200017 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190611200027 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190610200032 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190609200013 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190608200023 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190607200028 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190606200048 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190605200119 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190604200017 scan/lib/scan/slack_poster.rb
fastlane-2.125.2 scan/lib/scan/slack_poster.rb
fastlane-2.126.0.beta.20190603200020 scan/lib/scan/slack_poster.rb