1

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:

language: go
sudo: required
go:
   - tip
notifications:
  email:
     on_success: change
     on_failure: always

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

icza
  • 389,944
  • 63
  • 907
  • 827
Long
  • 69
  • 1
  • 9

2 Answers2

2

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

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

Or if you are using a Makefile:

script: sudo -E env "PATH=$PATH" make
Zorawar
  • 6,505
  • 2
  • 23
  • 41
Glaslos
  • 2,872
  • 1
  • 21
  • 31
  • 1
    en ... , i have done it . but it says : go not found if use sudo go test , and go test well use. so how to set in travis and i can find go command with sudo . – Long Dec 17 '16 at 11:25
  • Try with -E https://stackoverflow.com/questions/8633461/how-to-keep-environment-variables-when-using-sudo – Glaslos Dec 18 '16 at 13:32
  • 1
    Thanks, this help me a lot ^.^, finally , i use sudo - E env "PATH=$PATH" go test and can run it – Long Dec 19 '16 at 08:49
-2

script: - sudo env "PATH=$PATH" npm test

Unitech
  • 5,781
  • 5
  • 40
  • 47