【发布时间】:2020-10-13 14:18:35
【问题描述】:
我正在尝试使用 Codecov 提供的 codecov-bash 脚本将覆盖率报告上传到 codecov.io。 bash 脚本无法在运行 alpine:edge docker 映像的 Gitlab CI 上运行。
以下是错误:
$ /bin/bash <(curl -s https://codecov.io/bash)
/bin/sh: eval: line 107: syntax error: unexpected "("
这是我的.gitlab-ci.yml 文件的相关部分:
after_script:
- apk -U add git curl bash findutils
- /bin/bash <(curl -s https://codecov.io/bash)
脚本的第 107 行在 show_help() 函数内,就在 This is non-exclusive, use -s "*.foo" to match specific paths. 下方:
show_help() {
cat << EOF
Codecov Bash $VERSION
Global report uploading tool for Codecov
Documentation at https://docs.codecov.io/docs
Contribute at https://github.com/codecov/codecov-bash
-h Display this help and exit
-f FILE Target file(s) to upload
-f "path/to/file" only upload this file
skips searching unless provided patterns below
-f '!*.bar' ignore all files at pattern *.bar
-f '*.foo' include all files at pattern *.foo
Must use single quotes.
This is non-exclusive, use -s "*.foo" to match specific paths.
-s DIR Directory to search for coverage reports.
Already searches project root and artifact folders.
-t TOKEN Set the private repository token
(option) set environment variable CODECOV_TOKEN=:uuid
-t @/path/to/token_file
-t uuid
-n NAME Custom defined name of the upload. Visible in Codecov UI
-e ENV Specify environment variables to be included with this build
Also accepting environment variables: CODECOV_ENV=VAR,VAR2
-e VAR,VAR2
-X feature Toggle functionalities
-X gcov Disable gcov
-X coveragepy Disable python coverage
-X fix Disable report fixing
-X search Disable searching for reports
-X xcode Disable xcode processing
-X network Disable uploading the file network
-X gcovout Disable gcov output
-X html Enable coverage for HTML files
-X recursesubs Enable recurse submodules in git projects when searching for source files
-N The commit SHA of the parent for which you are uploading coverage. If not present,
the parent will be determined using the API of your repository provider.
When using the repository provider's API, the parent is determined via finding
the closest ancestor to the commit.
-R root dir Used when not in git/hg project to identify project root directory
-F flag Flag the upload to group coverage metrics
-F unittests This upload is only unittests
-F integration This upload is only integration tests
-F ui,chrome This upload is Chrome - UI tests
-c Move discovered coverage reports to the trash
-Z Exit with 1 if not successful. Default will Exit with 0
-- xcode --
-D Custom Derived Data Path for Coverage.profdata and gcov processing
Default '~/Library/Developer/Xcode/DerivedData'
-J Specify packages to build coverage. Uploader will only build these packages.
This can significantly reduces time to build coverage reports.
-J 'MyAppName' Will match "MyAppName" and "MyAppNameTests"
-J '^ExampleApp$' Will match only "ExampleApp" not "ExampleAppTests"
-- gcov --
-g GLOB Paths to ignore during gcov gathering
-G GLOB Paths to include during gcov gathering
-p dir Project root directory
Also used when preparing gcov
-k prefix Prefix filepaths to help resolve path fixing: https://github.com/codecov/support/issues/472
-x gcovexe gcov executable to run. Defaults to 'gcov'
-a gcovargs extra arguments to pass to gcov
-- Override CI Environment Variables --
These variables are automatically detected by popular CI providers
-B branch Specify the branch name
-C sha Specify the commit sha
-P pr Specify the pull request number
-b build Specify the build number
-T tag Specify the git tag
-- Enterprise --
-u URL Set the target url for Enterprise customers
Not required when retrieving the bash uploader from your CCE
(option) Set environment variable CODECOV_URL=https://my-hosted-codecov.com
-r SLUG owner/repo slug used instead of the private repo token in Enterprise
(option) set environment variable CODECOV_SLUG=:owner/:repo
(option) set in your codecov.yml "codecov.slug"
-S PATH File path to your cacert.pem file used to verify ssl with Codecov Enterprise (optional)
(option) Set environment variable: CODECOV_CA_BUNDLE="/path/to/ca.pem"
-U curlargs Extra curl arguments to communicate with Codecov. e.g., -U "--proxy http://http-proxy"
-A curlargs Extra curl arguments to communicate with AWS.
-- Debugging --
-d Don't upload, but dump upload file to stdout
-q PATH Write upload file to path
-K Remove color from the output
-v Verbose mode
EOF
}
我已经尝试了很多方法来解决这个问题,但我找不到解决方案。在他们的 GitHub 存储库中,有一个似乎相关的问题,但建议的解决方案对我不起作用:Failing on busybox 1.26, incorrect flags passed to find。
您可以在此处找到作业的完整日志,第 434 行:https://gitlab.com/gaspacchio/back-to-the-future/-/jobs/788303704
【问题讨论】:
-
所以使用 bash,而不是
sh。/bin/sh:- 高山运行sh。虽然<(...)是一个bash 扩展,但busyboxssh不可用。你可以bash -c '/bin/bash <(...)' -
我正在尝试使用
bash,您可以在.gitlab-ci.yml文件中看到。但是,Alpine Linux 似乎无论如何都使用sh。 -
我刚刚尝试了您的建议@KamilCuk,错误只是向下移动了一行。不过它仍在使用
/bin/sh。 -
因为你没有添加尾随
'.... 是bash -c '/bin/bash <(curl -s https://codecov.io/bash)'而不是bash -c '/bin/bash <(curl -s https://codecov.io/bash)- 去喝杯咖啡吧。 -
成功了。你是个天才。为什么它起作用了?顺便说一句,我正在为您提供咖啡@KamilCuk,您刚刚拯救了我的一天!
标签: bash docker gitlab-ci codecov