Jenkins pipeline throwing 'go: command not found' error while running shell script

601 Views Asked by At

I am trying to create pipeline using blue ocean(jenkins), but i am getting this error:

Error message

I have performed all the steps (linking github, creating stage etc.) and while creating the pipeline I used shell script to test the command go test ./... as step.

Here is the link of the repo https://github.com/SajjanYadav/go-webapp-sample

I tried to find the solution and got to know that may be the path of go is not in the path variable, but even after adding the path (PATH=$PATH:/usr/local/go/bin) the error keeps on coming.

1

There are 1 best solutions below

0
ChaKu On

As @David commented, it depends on how you update your PATH variable. If you're trying to add go only in your Jenkinsfile, you might be better off using environment { PATH = '/usr/local/go/bin:$PATH } or use withEnv(PATH='$PATH:/usr/local/go/bin') { sh 'go test' }