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
  • 342,548
  • 56
  • 784
  • 738
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,037
  • 2
  • 19
  • 40
Glaslos
  • 2,798
  • 1
  • 20
  • 30
  • 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,363
  • 5
  • 38
  • 45