grep - grep xcov 结果转换为 fastfile 中的变量
问题描述
我正在使用 fastlane,但我不想使用 xcov slack 功能,我正在将所有信息编译到进一步发送的同一个 slack 通知中。
lane :run_my_stuff do
xcov(project: "my-app.xcodeproj",
scheme: "my_scheme",
output_directory: "xcov_output",
only_project_targets: true)
$coverage=sh("grep \"(\d+.\d+\%)\"")
slack(message: "",
success: true,
slack_url: "https://hooks.slack.com/services/xxxxxxxx...",
default_payloads: [],
link_names: true,
attachment_properties: {
fields: [{
title: "Coverage",
value: $coverage
}
]
})
end
这不起作用,但我相信它显示了我正在努力实现的目标。我也尝试使用:
$coverage=sh("cat xcov_report/index.html | grep '\d\+.\d\+\%' | head -1")
解决方案
我发现我的代码出了什么问题。几件事(叹气)
- 不需要美元符号
coverage=sh("cat xcov_output/index.html | grep '\\d\\+.\\d\\+\\%' -o | head -1")
我所在的文件夹和我想的不一样。所以我将输出路径更改为
fastlane/xcov_output
正则表达式的转义是不够的。所以我加倍了
结尾
xcov(project: "my-app.xcodeproj",
scheme: "MOCK",
output_directory: "fastlane/xcov_output",
only_project_targets: true)
release_notes=sh("git tag -l --format='%(contents)' $(git describe $(git rev-list --tags --max-count=1))")
coverage=sh("cat xcov_output/index.html | grep '\\d\\+.\\d\\+\\%' -o | head -1")
slack(message: " b(#{number_of_commits}) <@XXXXX>",
success: true,
slack_url: "https://hooks.slack.com/services/...",
default_payloads: [],
link_names: true,
attachment_properties: {
fields: [
{
title: "Release notes",
value: release_notes
},
{
title: "Environment",
value: environment.capitalize
},
{
title: "Coverage",
value: coverage
}
]
}
)
推荐阅读
- webpack - 配置 webpack、coffeescript、mocha 和 mochapack 的问题
- entity-framework - 错误无法更新数据库以匹配当前模型,因为有待处理的更改
- javascript - 在 JS 中从 chrome 扩展中保存和读取数据
- xamarin.forms - Xamarin Forms CollectionView 无法正常工作(支持库?)
- r - R 将 SQLiteResult 记录集导出到 Excel 或 csv
- interface - 在启动时使用 systemd 启用 vcan0 接口
- android - 如何通过定时通知启动我的服务
- syntax - 尝试使用 getUserMedia(next.js 应用程序)时出现 SyntaxError Unexpected Token
- node.js - 使用 node.js 中的子方向重定向(快速)
- visual-studio - 有没有办法在 Visual Studio 的“命令行参数”启动选项中使用相对路径?