Travis-ci在使用go test时需要root权限,如何设置?

huangapple go评论107阅读模式
英文:

Travis-ci needs root privilege when using go test, how to set it?

问题

我有一个 Go 的测试文件,需要 root 权限来运行它(go test)。如何在 Travis CI 中设置它?

以下是 yml 文件的内容:

  1. language: go
  2. sudo: required
  3. go:
  4. - tip
  5. notifications:
  6. email:
  7. on_success: change
  8. on_failure: always

在 git push 后,travis-ci 构建失败,使用默认配置。

英文:

I have Go test file and it needs root privilege to run it (go test). How to set it in Travis ci?

Here is yml:

  1. language: go
  2. sudo: required
  3. go:
  4. - tip
  5. notifications:
  6. email:
  7. on_success: change
  8. on_failure: always

After git push, travis-ci build failing with default configure.

答案1

得分: 2

在Travis中,你可以使用sudo命令来以root权限运行你的测试。如果你想要以root权限运行测试,可以修改脚本部分:

  1. script: sudo -E env "PATH=$PATH" go test ./...

或者如果你正在使用Makefile:

  1. script: sudo -E env "PATH=$PATH" make
英文:

In travis you can use sudo so if you want to run your tests with root permission, change the script section:

  1. script: sudo -E env "PATH=$PATH" go test ./...

Or if you are using a Makefile:

  1. script: sudo -E env "PATH=$PATH" make

答案2

得分: -2

  1. 脚本:
  2. - sudo env "PATH=$PATH" npm test
英文:
  1. script:
  2. - sudo env "PATH=$PATH" npm test

huangapple
  • 本文由 发表于 2016年12月15日 21:26:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/41165326.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定