jenkins: windows xp, windows 7 slave cannot execute commands - windows

I have a Arch Linux master that drive 2 arch linux slaves, 1 windows xp slave and 1 windows 7 slave. Linux part is all ok, I managed in some way to start windows slave using automatic execution and slave.jar. I have an external program that need to be executed and it's installed on c:\program files (x86) on windows7 and on c:\programs on windows xp.
I went on path variables and inserted the two path on the two systems, but when I try to run jenkins build it says "command not found"
I tryed to place 2 bat files in c:\ poining to the right place, based on every system, but it says c:\build.bat command not found. I can see the file in the right place...
How do you manage executables placed in different places on different computers?
there's a better way to run the program?
I can change everything about this installation, the only thing I need it to find a way for starting that program.
thank you for your help.

Have you verified that the changes you made to the system path were actually saved? Make sure both of the slaves have been rebooted and then test this via a standard command line window.
If the program you're trying to execute is actually on the path, you could also look at the Envfile Plugin.

After adding new paths to your environment variable PATH you need to restart jenkins slave service in order to allow it to use these new PATHs.

I solved the problem changing the way jenkins start the job on the slave. I used "Execute shell" and some program are executed. I changed "Execute shell" with "Execute windows batch command" and everything works fine.

Related

How to enable bash commands in Windows CMD?

I've two Windows machines and both have bash installed. However, they differ in the way bash starts up:
Machine 1:
Typing "bash" starts the bash. Then I can type commands like ls.
Machine 2:
It seems like it starts bash and directly runs ls in it, by only typing "ls". After that it switches back to CMD automatically, like this:
Does anyone know which setting enables the behavior of machine 2? Everything looks the same for me. It's a nice feature and I want to enable it on machine 1 as well.
Bash on Ubuntu on Windows executables (binaries) cannot run from Windows applications such as cmd.exe or PowerShell.exe - Windows doesn't even see them as executable.
The likeliest explanation is that you've installed a separate Unix emulation environment such as GnuWin, which comes with native Windows binaries.
To see the location of your - by definition Windows-native - ls executable, run where ls, which will probably tell you what product it came with, such as
C:\Program Files (x86)\GnuWin32\bin\ls.EXE.
Note that the Ubuntu on Windows binaries are stored in a user-specific manner in
%LOCALAPPDATA%\lxss\rootfs\bin, but that is a moot point, given that you cannot invoke them from Windows.
In Windows 10, there is a built-in Linux subsystem (one of the greatest features of Windows 10). It gives you almost a complete Linux shell for various distributions, and you can almost do anything with it (user mode).
I bet it is installed on your first computer, and you are using that subsystem. In the latest version of this subsystem, you can run both Linux executables and Windows exe files.

Jenkins on Windows 10 with Bash

I'm currently setting up a Jenkins server on Windows 10, in the hope of being able to make the build scripts more cross platform I was hoping to take advantage of the bash environment that is available in Windows 10.
I hoped this could be done just by setting the path to the shell in Jenkins to be the bash executable, however I've encountered some problems with trying to get this to work.
Firstly when I set the path to be C:\Windows\System32\bash.exe but Jenkins didn't seem to be able to see this path.
I assumed this was because Jenkins was running as 32-bit and changed the path to be C:\Windows\sysnative\bash.exe but when I try and use this I get the error
[workspace] $ C:\Windows\sysnative\bash.exe -xe C:\Users\Jenkins\AppData\Local\Temp\hudson4346151084156392102.sh
Error: 0x80070005
Build step 'Execute shell' marked build as failure
I think I'm poking around in the dark a bit so I didn't know if anyone had any experience of trying to use the bash shell on Windows 10 within Jenkins?
The error 0x80070005 usually appears during Windows Update or by specific applications, because of the .DLL files permission being denied. Look at your permissions and then try again.
You can run this on Windows in order to execute a bash shell script:
bash -c /mnt/c/Users/$LOGNAME/Downloads/abc.sh
Make sure that the script is executable (chmod +x)
(Only works on Windwos 10 with a linux subsystem installed)

How do you install dependent programs with a batch file?

I'd like to install two programs (program.exe, program_sp1.exe) via batch script.
The problem is that the first install adds environment variables that are needed by the 2nd.
Is there a good way to run the 2nd installer in a new command prompt so the values are picked up, but without user interaction to close it?
I've tried this in a Windows 7 Machine.
You should be able to run program.exe and the run cmd and then run your program_sp1.exe, and an exit as the cmd is running another version in itself with the updated environment variables.

How to run a jenkins pre-build step that depends upon the jenkins slave OS?

In my company, jenkins is configured with one Windows slave and (to come soon) one Mac slave. we want to have a Glassfish domain started as pre-build step, and domain stopped as post-build.
From what I understand, I have to run a "windows batch file pre-build step" on Windows, and a "shell script pre-build step" on Mac.
Can I put both in pre-build steps ? Or should I use an other solution (and if so, which one) ?
You cannot put both in the same job. When the job runs on Mac slave, the "windows batch" will fail. When the job runs on Windows slave, the "shell" will fail.
Why are you trying to add both? I understand that you need the relevant pre-build step, but why are you trying to make the job generic to be executed on either Mac or Windows? Usually running a Mac slave serves a specific purpose (such as doing an Xcode iOS build that cannot be done on a Window), and you restrict that job to run only on Mac slave
If you really need the ability to run either Windows or Mac shell, then you should have a look at XShell plugin
https://wiki.jenkins-ci.org/display/JENKINS/XShell+Plugin
It allows you to execute a "shell" step, on either Windows shell or Mac shell. The plugin will take care of calling the correct shell, and will even do the file separator conversion for you (it will use \ for Windows, and / for Linux/Mac shell), but the commands you put there must be executable in both shells (i.e. it will not translate rm into del for you). The Plugin page gives an example how you can "wrap" the commands into a batch and shell file.

Hudson -- Windows execute windows batch command

I currently running the following commands on a hudson slave deployed on a windows machine.
dir
cmd
mvn clean install
I get the following return on the build.
mvn' is not recognized as an internal or external command,
operable program or batch file.
I have set the correct path on the node which points to the hudson installation on the windows machine.
I have also set the correct Path for JAVA and M2_HOME on the windows slave machine.
I was hoping for the correct way to call maven and maybe another *.bat file if need be in the future.
Please and thank you
I still haven't figured this out. A good work around is to use the full path to mvn to run it. Which worked for me.

Resources