Jenkins dotnet command not found

Viewed 7736

I am trying to setup CI locally with Jenkins on OSX, however I am having some issues when trying to execute shell commands. Here are the commands I am trying to run in the Jenkins configuration:

cd /Users/username/projectname
dotnet build HD-Project.sln

However, when I try and build the project, I get the following errors:

Building in workspace /Users/Shared/Jenkins/Home/workspace/HD-Build
[HD-Build] $ /bin/sh -xe 
/Users/Shared/Jenkins/tmp/jenkins2699993427980474696.sh
+ cd /Users/username/projectname
+ dotnet build HD-Project.sln
/Users/Shared/Jenkins/tmp/jenkins2699993427980474696.sh: line 3: 
dotnet: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Any help would be greatly appreciated, thanks.

2 Answers

This happens because the installation package does not add the dotnet executable location to the PATH environment variable. This issue is mentioned in https://github.com/dotnet/core/blob/master/cli/known-issues.md#users-of-zsh-z-shell-dont-get-dotnet-on-the-path-after-install, but apparently it does not affect only zsh users. You need to add this path manually.

In my case the path was /usr/local/share/dotnet, so I ran (from the command line):

export PATH=/usr/local/share/dotnet:$PATH

Taken from https://github.com/dotnet/cli/issues/4357

Related