Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins dotnet command not found

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.

like image 244
Craig Avatar asked Nov 13 '17 21:11

Craig


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

like image 79
stepheaw Avatar answered Oct 22 '22 19:10

stepheaw


I got this working, and was successfully able to run dotnet commands through an executed shell via Jenkins.

To run dotnet commands, the .NET SDK needs to be installed on the Jenkins build server. Instructions on how to install the .NET SDK can be found here: https://www.microsoft.com/net/learn/get-started/macos for all OS - Linux, MacOS and Windows.

like image 20
fuzzi Avatar answered Oct 22 '22 20:10

fuzzi