Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (12.7k points)

I am using Jenkins 2.46.1 I have a build pipeline plugin installed and I want to execute a Windows batch file in it. The batch file should execute in a new command window and not on jenkins console output. I give the below Jenkins pipeline groovy script:

node {  

    stage 'Init'

    bat '''

        call C:\\myprj\\mybat.bat stop

        EXIT /B 0


    stage 'Deploy'

    bat '''call C:\\myprj\\mybat.bat'''


In the init stage, I want to kill the process if it is already open and in stage deploy it should open a new command window and run my batch file. The problem is that the above does not work. The build is succesful but no command window opens up. Pls suggest

1 Answer

0 votes
by (29.5k points)
hi, try using the following command

bat 'start cmd.exe /c C:\\myprj\\mybat.bat'

This will launch a new command windows (cmd.exe) and run the batch file given

Related questions

Browse Categories