How to pass dotnet tools in to a docker - docker

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

Related

Chaining Dockerfiles - after FROM, running npm no longer works?

I'm experimenting with docker. I have a simple dockerfile, which includes java and node.
https://github.com/Quafadas/scala-mill
https://github.com/Quafadas/scala-mill/blob/master/Dockerfile
It's published to dockerhub. Now, I'd like to build an application downstream
FROM quafadas/scala-mill:latest
RUN java -version
#This doesn't work :-(.
RUN npm --version
The command RUN npm --version works in the base image linked above, but apparently, not when I'm building on top of it using the FROM directive. Is anyone able to help me understand why?
/bin/sh: npm: command not found
15:15:19
The command '/bin/sh -c npm --version' returned a non-zero code: 127
enter code here
``
There seem to have been a few recent commits to the repo which has apparently fixed the issue! I was able to build and run the Dockerfile to get the npm version without any issues!
In case you need additional modules (such as npm) to be installed on a base image that doesn't provide it, use a multi-stage Dockerfile with different FROM commands to get your necessary dependencies onto a single Dockerfile and a docker image later. Reference.

configuration JMeter wtth Jenkins by Docker container

I did functional tests in JMeter (backend application).
I have in Jmeter 42 functional tests and I launch this in one docker container
Now I configuration JMeter with Jenkins by docker container -
My dockerfile is following:
[https://pastebin.com/Aq9A9eqh][1]
To automatically run these tests regullary,
I created docker - container and when I run build execution on Jenkins, I had a following error:
https://pastebin.com/365kLWXB
What is wrong?
How is the best way to improve this?
What can I improve further?
I know that I must add a java jdk, but I don't know how to add to my dockerfile?
https://pastebin.com/Aq9A9eqh
When I added:
FROM openjdk:8u162-jre-slim-stretch
ARG GITHUB_OAUTH_TOKEN
it didn't run.
With regards to your current setup your Docker image doesn't have Java installed therefore you cannot launch JMeter.
You can fix it by replacing these line:
RUN apt-get install -y git
with this one:
RUN apt-get install -y git default-jre
With regards to "improve further" be aware that according to JMeter Best Practices you should always be using the latest version of JMeter so consider replacing JMeter version 3.3 with somethine more recent, as of now it's JMeter 5.0, you can always check JMeter Downloads page for current release details.

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.
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

command not found when executed from jenkins, but runs on mac agent

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.

Grunt integration with Jenkins on windows 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}

Resources