Batch script command automatically stops batch script - batch-file

I am experiencing a strange issue with the following batch script run via cmd.exe on Windows:
#echo off
gradle wrapper
gradlew build
pause
This batch script only ever executes the first command, i.e. gradle wrapper. After that, the batch script automatically terminates and the command gradlew build is never executed.
Is there any way I can force the batch script so that it cannot be stopped by gradle wrapper and continues its execution normally after gradle wrapper has been called?

I have a feeling you may need to precede with call:
call gradle…

Related

VSTS, Launching Android emulator from a batch file not working as expected

I am trying to launch an Android emulator from a batch file inside my build definition, with the next command:
start /WAIT "Start Emulator" "C:\Program Files (x86)\Microsoft Emulator Manager\1.0\emulatorcmd.exe" launch /sku:Android /id:97522427-7A5E-4F3B-96A8-B9F9F0C0423A
I tried to add the build step as a command line, and a batch script.
Problem: The script is working right, and opening the emulator and wait for it to fully open, but once script finishes executing and console closes, the emulator is closing as well.
I tried to run the script directly on build server, and it works fine without closing emulator, but when queued as a build step, I am facing the above problem.
Question: How can I force the emulator to stay open after batch file finishes executing?
EDIT:
It looks like the build definition task terminates all processes it created in the defined step, I have tried multiple script, tried cmd /k and tried the /b and tried to create another batch file that actually calls this one or start it, yet no results. I am still waiting for any possible solution.
Alright, I tried a lot of scripts in batch files, and I tried to run it from command line, after a lot of time waste and getting tired, I decided to give PowerShell task a try to fix my problem. I ended up with this:
Start-Process -FilePath "C:\Program Files (x86)\Microsoft Emulator Manager\1.0\emulatorcmd.exe" -ArgumentList "launch /sku:Android /id:97522427-7A5E-4F3B-96A8-B9F9F0C0423A" -Verb runas
Start-Sleep -s 60
This made the emulator start, and stays running even after PowerShell script ends.

Jenkins Batch contains .exe command inside

I have a Jenkins job that runs an "Execute Windows batch command", inside that batch I have a.exe, Jenkins job fails with this message:
"a.exe is not recognized as an internal or external command"
but when I run manually batch that have inside a.exe is working.
Did you try Windows Exe Runner Plugin, I have been using it for a while and it let me run .exe from jenkins.

Make Jenkins start a Batch without running forever?

How would I go about making a Jenkins server start a .bat file, that runs forever as it starts a server program, without having Jenkins run forever until the bat file is ended manually or by error?
Could this be solved by making Jenkins call a bat file which calls the server bat file thar runs forever?
You need to detach execution from the main process, similar to the & operator in Linux.
If you bath file is named run-forever.bat, then create another batch file named forever-starter.bat that does this :
#start "" cmd /c run-forever.bat

Nunit result xml is not updated during Jenkins build

I have configured NUnit tests to run after build completed.(Jenkins)
I added following on Excecute windows batch command window in Jenkins.
rmdir ClickOnceInstall /Q /S
mkdir ClickOnceInstall
CD BuildScripts
Start.bat
"C:\Program Files (x86)\NUnit 2.6.2\bin\nunit-console-x86.exe" AA.Tests\bin\x86\Release\AA.Tests.dll /xml=nunit-result.xml
It seems Execute unit test command doesn't create result file as specified name and marked as failed. However, when I run the nunit test command manually it creates the file. Next time build through Jenkins, result xml file does not seem to be updated but it doesn't fail.
am I missing any configuration or something else?
It would help if you would paste the console log.
However, my first guess is to ask you to add call to your batch file statement:
call Start.bat
If that batch file has an exit /b statement (even with 0), it will quit the whole calling step (i.e. "Execute windows batch command") without getting to your last statement (i.e nunit command).
Using call in front of the batch file will make sure that control is returned to the calling step.

Hudson won't execute windows batch commands after running a .bat script

In hudson, after running a .bat script my slave refuses to run anything that comes afterward. It instead just said that it finished with a success.
Trying do a
call yourscript.bat
instead of just a
yourscript.bat

Resources