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.
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.
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
I really need some help to build a simple project with Cmake with Jenkins.
I downloaded the Cmake plugin on Jenkins.
I configured it in the job :
and in Global Tool Configuration :
But then it doesn't work. Here are the end of the logs before the Jenkins build fails :
+ ls
CMakeLists.txt
MathFunctions
TutorialConfig.h.in
build
tutorial.cxx
[build] $ cmake /var/jenkins_home/workspace/Project
ERROR: Cannot run program "cmake" (in directory "/var/jenkins_home/workspace/Project/build"): error=2, No such file or directory
Build step 'CMake Build' marked build as failure
Finished: FAILURE
I don't understand why there is no proper step-by-step tutorial to create something that common as a Cmake build with Jenkins.
In the end, I managed to pull it off.
I uninstalled the Cmake plugin which seems to be useless apparently...
And I simply installed Cmake manually on the Jenkins container.
On root I used :
dotnet tool install --global dotnet-sonarscanner --version 4.7.1to install sonarscanner
and it's working:
SonarScanner for MSBuild 4.7.1
Using the .NET Core version of the Scanner for MSBuild
WARNING: Please specify the command 'begin' or 'end' to indicate whether pre- or post-processing is required. These parameters will become mandatory in a later release.
Post-processing started.
But in a docker it isn't:
root#3bea636a6418:/# dotnet sonarscanner
bash: dotnet: command not found
I tried to pass it:
export PATH="$PATH:/root/.dotnet/tools"
but with no luck
ps. ...and everything because of sonarscanner could not find java on docker:
SonarScanner for MSBuild 5.2
Using the .NET Core version of the Scanner for MSBuild
Post-processing started.
Calling the SonarScanner CLI…
Could not find ‘java’ executable in JAVA_HOME or PATH.
The SonarScanner did not complete successfully
14:43:39.402 Post-processing failed. Exit code: 1
Cleaning up file based variables
ERROR: Job failed: exit code 1```
Install all the dependencies for your dotnet tools to work, ldd command can help you with this, and make sure all software required can be found also, for example can be found on the PATH variable if required.
to help you use interactive bash on the docker container, and add to your dockerfile if this works.
docker exec -it (container) bash
docker images usually installs what is required only, so you add the tools only to run your software successfully.
- apt-get update
- apt-get install --yes openjdk-11-jre
solved problem
ps. it's not that obvious because in docker bash when I run java -version I get answer that java is already installed
I am trying to configure a simple startup project. I am pulling the code from GIT and trying to create a build. Getting this error on local Jenkins,
[Flutter-Starter] $ /bin/sh /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/jenkins102165218853380431.sh
/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/jenkins102165218853380431.sh: line 3: flutter: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
My Execute Shell has
#!/bin/sh
flutter build apk --debug
Flutter is installed and is working on my system. As the same command is creating the android build for me on Studio.
Here is the environment, from .bash_profile file.
...
export PATH=$PATH:/Users/rana.singh/Downloads/softwares/flutter/bin
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export PATH=$PATH:Library/Android/sdk/platform-tools/
Not sure what is going wrong.
This is what I was missing. Just in case it could help someone else.
Remind you I had this in my .bash_profile already still, it was needed on Jenkins.
Goto Jenkins > Manage Jenkins > Configure System > Global Properties >
I have Jenkins set up on a Windows machine, with a mac slave configured.
When I run the command nuget directly from terminal, it works. However when I try running the nuget command from Jenkins as a executable shell, I get command not found
[iOS Build] $ /bin/sh -xe /var/folders/hr/b_p9skp53178b45895w2htw80000gn/T/hudson278562289764277217.sh
+ nuget restore '/Users/a/Jenkins/workspace/iOS Build/App/Acquaint.Native.sln'
/var/folders/hr/b_p9skp53178b45895w2htw80000gn/T/hudson278562289764277217.sh: line 2: nuget: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
I already have the directory where nuget resides configured in the PATH environment variable
maybe:
echo $PATH within your job to ensure it's configured as you expect when the job runs.
try including the full path to nuget. run /usr/local/bin/nuget restore... (or wherever nuget is found) instead of nuget restore... to determine if it's really a PATH issue.
I am running Jenkins on Tomcat7 - Windows 7. I have provided the node bin path in my jenkins configuration. Then running a shell script as follows:
echo $PATH
node --version
npm install -g grunt-cli
npm install
grunt cssmin
As suggested in other post Jenkins integration with Grunt, I have restarted my jenkins several times, and tried to work on all the answers written in that post, but still it shows error, grunt: command not found.
Error stack trace from jenkins console output:
/c/apache-maven-3.2.5/bin:/c/Program Files/Java/jdk1.7.0_79/bin:/c/Program Files/nodejs/bin:/c/Program Files/Java/jdk1.7.0_79/bin:/c/Program Files/nodejs/:
+ node --version
v0.10.30
+ npm install -g grunt-cli
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\grunt -> C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt
grunt-cli#0.1.13 C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\grunt-cli
├── resolve#0.3.1
├── nopt#1.0.10 (abbrev#1.0.7)
└── findup-sync#0.1.3 (lodash#2.4.2, glob#3.2.11)
+ npm install
npm WARN package.json Trademust#1.0.0 No repository field.
+ grunt cssmin
C:\Program Files\Apache Software Foundation\Tomcat 7.0\temp\hudson2968878175697925824.sh: line 6: grunt: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
I have also followed the steps mentioned on this site grunt-on-jenkins
package.json and Gruntfile.js are in root directory the very first time when I executed the jenkins build, grunt installed all modules from my gruntfile.js, and after that in all other build's its showing the above output.
Can anyone please check what's going on wrong here.
After searching a lot, I found where my grunt is installed. As far as jenkins build is concerned it installs in drive:/.jenkins....../workspace/node_modules/.bin.
After providing this path in jenkins using shell script export path=$PATH:drive:/.jenkins....../workspace/node_modules/.bin, grunt started executing.
Also what I learnt in this process was checking where the executable's are available on system path or which path jenkins refers to is using which "executable_name" without qoutes. you can use this command both on windows as well as linux. Ex: which grunt will show the path where grunt executable file is present.
From the error message it seems, sheel is not able to find grunt. Could you please check if it is present in the $PATH variable. On which node this shell script is running? You cab check the $PATH of the particular node. You can also add grunt installation path to $PATH variable during the shell script.
grunt_path="grunt_installtion_path"
export PATH=${PATH}:${grunt_path}