Environment:
First Test
Second Test
I create a Declarative Pipeline as follows:
pipeline {
agent { label 'SiebelWindows' }
stages {
stage('Test Bat') {
steps {
bat 'C:\\Jenkins\\mytest.bat'
//bat 'start cmd.exe /c C:\\Jenkins\\mytest.bat'
//call C:\\Jenkins\\mytest.bat
}
}
}
}
In this case the build FAIL with error "cmd is not recognized as a internal o external command"
So, why can I run the .bat with a non-declarative pipeline, but fails with a declarative pipeline?
If you have installed jenkins on windows and are facing this error while running maven command from your jenkins pipeline: 'mvn' is not recognized as an internal or external command, operable program or batch file, then the first step for you is to check whether the environment variables are setup correctly.
You can resolve this issue in three ways: First, use the full path of the executable file to launch the program. Second, add the program path to Windows environment variables. Finally, move the files to the System32 folder.
When I display the "Path" and the "PATH" variables, this was the result
Original_Path
The solution was redefine the PATH enviorement variable, like this
environment {
PATH = "C:\\WINDOWS\\SYSTEM32"
}
@JustAProgrammer aske me if C:\WINDOWS\SYSTEM32 was in the PATH of my Windows machine, and that is correct, but seems like Jenkins master do not know the slave's Windows Path.
I resolve my issue, but I still looking for a complete solution, I need to set the PATH enviorement variable with ALL the path, no only C:\WINDOWS\SYSTEM32
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With