Jenkins throws "Executable not found in $PATH" - jenkins

I have installed kompose in my Jenkins machine through CLI and it is successfully installed.
I am trying to build a job which uses this "kompose" executable but it fails with "Exectable not found in the $PATH" error.
Error:
+ skaffold init --compose-file docker-compose.yaml
time="2019-11-13T10:39:00Z" level=fatal msg="running kompose: exec: \"kompose\": executable file not found in $PATH"
Please let me know if I need to make anymore changes to communicate the executable to Jenkins

On your Jenkins job has executed, you can review its environment variables (on the left side of the job execution instance page)
Check the PATH value and see if it includes where you have installed kompose.
Check also which user is actually running Jenkins: its $PATH might differ from your current local user.

Related

java.io.IOException: Cannot run program "sh"

I am trying to run postman collection in jenkins getting below error Could you please help on it . Thanks.
Running as SYSTEM
Building in workspace C:\Users.jenkins\workspace\Postman
[Postman] $ sh -xe C:\Users\AppData\Local\Temp\12\jenkins4131098184637934114.sh
The system cannot find the file specified
FATAL: command execution failed
Caused: java.io.IOException: Cannot run program "sh" (in directory "C:\Users.jenkins\workspace\Postman"): CreateProcess error=2, The system cannot find the file specified
The answer was provided here, you have two options:
On your {jenkinsUrl}/job/{jobName}/configure build step you can choose "Execute Windows batch command" rather than "Execute shell"
In Manage Jenkins -> Configure System -> Shell, set the shell path
as
C:\Windows\system32\cmd.exe

Jenkins user gets "Permission denied" at deploying

Deploying a PDF documentation Jenkins executes a simple batch file:
#echo off
REM
REM Adapt the filepath as needed
REM
set PDF_OUTPUT_DIR="F:\svnWorkingCopy\kostra\trunk\DITA\__out_pdf"
set PDF_DEPLOY_DIR="\\FILE-SRV01\Austausch\Setup_Masterbuild\KOSTRA_AKVS\Deutsch\KostraAKVS"
del %PDF_DEPLOY_DIR%\KostraUserManual.pdf /F /Q
copy %PDF_OUTPUT_DIR%\kostra.pdf %PDF_DEPLOY_DIR%\KostraUserManual.pdf /Y
It quits with permission denied. End of console output (in German) is:
[kostra] $ cmd /c call C:\Windows\TEMP\jenkins1093559218605334188.bat
F:\svnWorkingCopy\kostra>F:\svnWorkingCopy\kostra\trunk\DITA\kostra-pdf-deploy.bat
Zugriff verweigert
0 Datei(en) kopiert.
Build step 'Windows Batch-Datei ausführen' marked build as failure
Archiviere Artefakte
Discard old builds...
#111 is removed because old than numToKeep
Sending e-mails to: fjk#akgsoftware.de
Finished: FAILURE
The Jenkins user is the user logged on that machine (Win Server 2012 r2) and has all Jenkins rights.
If I open CMD and execute the batch file manually, everything goes OK. Any idea why Jenkins refuses to copy the file? Is there a way to get a more detailed error msg. from Jenkins?
I see you are running Jenkins on windows. First check that if the user that started Jenkins is allowed to write on your directory. If that is not the case restart Jenkins with a user allowed to write in that directory.
Found the solution for my environment (Jenkins as Windows Service):
The default system user assigned to the Jenkins service must be changed to the logged on windows user.
Even after doing so Jenkins as a service doesn't know about mapped network drives, so you must change these to UNC paths if you have to deploy to a local network share.

How to pass parameters to remote shell in jenkins job

I am trying to pass a parameter to remote machine with ssh. I have used ssh plugin to add remote host.
# works for local shell
+ echo sdk
sdk
executing script:
BUILD="sdk"
# doesn't work for remote shell
export BUILD
echo "$BUILD"
BUILD=sdk: Command not found.
export: Command not found.
BUILD: Undefined variable.
[SSH] exit-status: 1
Build step 'Execute shell script on remote host using ssh' marked build as failure
Finished: FAILURE
I tried with double quotes, curly braces, export, but with nothing I am able to get the value of the parameter on remote shell. Can someone let me know if I am missing any configuration on jenkins?
The issue was with remote machine's default shell. It was tcsh, changed default shell to bash and it resolved the issue.

Jenkins build an image for Docker?

I'm a beginner with Jenkins CI integration with Docker.
My virtual machine tcp://192.168.99.100:2376
I created an image "personluz" with my SVN source code and the configuration like this image
image config
But the result is:
error
FATAL: Cannot run program "docker": error=2, No such file or directory
Could anyone have some idea? Thanks
First, the tag highlighted in the first picture is not the one for the personluz image (it is one of a dangling image)
The tag for personluz is b7782bf4cf30.
Second, a Cannot run program "docker": error=2 means that, in the context of the Jenkins slave executing the job, docker is not found in the Jenkins user $PATH. Make sure it is properly installed for that Jenkins user.

Restore snapshot before build in jenkins using virtualbox plugin

I'm using VirtualBox plugin on jenkins, to launch different builds retrieving sources from Git. I would like the environment on each VM to be clean by restoring a snapshot before starting them for a build.
I tried several things as https://wiki.jenkins-ci.org/display/JENKINS/Slave+Setup+Plugin.
Finally I don't think it it's a good solution as it is called after the git repository being clone... But I also tried to launch the slave "via the execution of a command on master", that takes as parameter the name of the vm and calls this script:
VBoxManage registervm "C:\Users\mfauvet\VirtualBox VMs\%1\%1.vbox
VBoxManage controlvm %1 poweroff
VBoxManage snapshot %1 restore SetEnvironment
VBoxManage startvm %1
ssh 192.168.120.1 -p 1310
But I have the following error:
C:\Program Files (x86)\Jenkins>"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" registervm "C:\Users\mfauvet\VirtualBox VMs\Jenkins-Ubuntu13.10\Jenkins-Ubuntu13.10.vbox"
VBoxManage.exe: error: Trying to open a VM config 'C:\Users\mfauvet\VirtualBox VMs\Jenkins-Ubuntu13.10\Jenkins-Ubuntu13.10.vbox' which has the same UUID as an existing virtual machine
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component Machine, interface IMachine, callee IUnknown
VBoxManage.exe: error: Context: "OpenMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())" at line 88 of file VBoxManageMisc.cpp
C:\Program Files (x86)\Jenkins>"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm Jenkins-Ubuntu13.10 poweroff
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
C:\Program Files (x86)\Jenkins>"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" snapshot Jenkins-Ubuntu13.10 restore SetEnvironment
0%...10%...20%...30%...40%...50%...
Progress object failure: RPC_S_SERVER_UNAVAILABLE 0x800706BA
Restoring snapshot 7f7cc1a3-7128-426a-bf74-9ffb0b3fbca8
C:\Program Files (x86)\Jenkins>"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm Jenkins-Ubuntu13.10
VBoxManage.exe: error: Could not find a registered machine named 'Jenkins-Ubuntu13.10'
VBoxManage.exe: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBox, interface IVirtualBox, callee IUnknown
VBoxManage.exe: error: Context: "FindMachine(Bstr(pszVM).raw(), machine.asOutParam())" at line 575 of file VBoxManageMisc.cpp
Does someone know how I could solve this ? Or is there a better way to restore a snapshot on my vm before launching them via Jenkins ?
Thanks for reading
I got this working, admittedly with VMWare.
Steps I took
add swarm plugin to master
Setup virtual machine and add swarm client
make sure client connects - will be in nodes in master
take snapshot with the slave client running (or initiate it on startup)
create a job on master which runs on your swarm slave
add multijob plugin to master create multijob project with normal steps to revert the VM
add a multijob phase
add the swarm slave job into the multijob phase
When running the job, the swarm slave job will wait for the VM to start before submitting jobs to it

Resources