Environment:
- Master Linux Jenkins server
- Two Windows slave nodes
- The windows slaves are running as a service
First Test
- I create a Pipeline and use a use a "Execute Windows batch command" in the build section
- In the Command box I put "C:\Jenkins\mytest.bat"
- I checked the box "Restrict where this project can be run" and write down the name of the Windows slave
- I built the pipeline and was successful
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?