首页 > 解决方案 > 如何通过 Fastlane 将测试报告附加到松弛通知

问题描述

我找不到非常简单(恕我直言)设置的解决方案。

在我的 iOS 应用程序中,我使用 Fastlane 通过scan命令运行测试。这会生成一个非常有用的 xpretty 测试报告 HTML 文件。

我想在测试结束时发送一个松弛通知,并附上我生成的 HTML 测试结果文件的链接。我正在使用一个安装在 minimac 上的运行器的 Gitlab 来运行我的 CI 管道。

到目前为止,我找不到此设置的解决方案。有人能指出我正确的方向吗?

标签: gitlab-cislackfastlane

解决方案


我希望您在最近 2 年内已经找到了解决方案。正如评论中所指出的,您可以使用 Slack 的 webhook。然后你可以像这样slack在你的步骤中运行命令:

platform :ios do
  before_all do
    ENV["SLACK_URL"] = "https://hooks.slack.com/services/T0A6LPW3A/B5B2SBA13/etc..."
  

  desc "Tests, builds and uploads to iTunesConnect"
  lane :appstore do

    ENV["LANE_NAME"] = "Flicker"
    ENV["BUNDLE_ID"] = "com.epri.fem"
    ENV["SCHEME_NAME"] = ENV["LANE_NAME"]
    ENV["TEAM_NAME"] = "Electric Power Research Institute"

    runConfiguration()

  end

  def runConfiguration()

    slack(
    message: ENV["LANE_NAME"] + ") Incoming from branch " + sh("git rev-parse --abbrev-ref HEAD") + " - " + sh("git rev-parse HEAD"),
    slack_url: ENV["SLACK_URL"]
    )

    sigh(team_name: ENV["TEAM_NAME"],
         app_identifier: ENV["BUNDLE_ID"],
         skip_certificate_verification: true) # Update Provisioing Profiles / Code Signing

    slack(
    message: "Finished updating provisioing profiles",
    default_payloads: [],
    slack_url: ENV["SLACK_URL"]
    )

    scan(
    scheme: ENV["SCHEME_NAME"],
    slack_url: ENV["SLACK_URL"]
    ) # run tests

    gym(scheme: ENV["SCHEME_NAME"],
        clean: true) # build the app

    slack(
    message: "Finished building app",
    default_payloads: [],
    slack_url: ENV["SLACK_URL"]
    )

    pilot(skip_submission: true,
          team_name: ENV["TEAM_NAME"])  #upload to test flight

    slack(
    message: "Finished archiving and uploading to iTunesConnect",
    default_payloads: [],
    slack_url: ENV["SLACK_URL"]
    )

  end

  error do |lane, exception|
    slack(
    message: exception.message,
    default_payloads: [],
    slack_url: ENV["SLACK_URL"]
    )
  end

推荐阅读