Nunit result xml is not updated during Jenkins build - batch-file

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.

Related

Writing Batch file that monitors a certain web page's status

The issue
I am trying to create a batch file that will execute the following two commands:
cd /some/path
dotnet run
that produces the following output:
It starts my localhost server.
Trying To Accomplish
What I would like to do is, put those two commands in a batch file and automatically open Chrome to the server address, HOWEVER, the dotnet command takes some time to finish. So somehow, I would have to keep monitoring localhost to see if it is available.
Any help would be appreciated. Although opening a CMD window, typing those 2 commands, and waiting a minute isn't all that much of a problem, it sure would be nice to just click on a batch file.
Thank you.
You can create a batch file like this code :
#echo off
Set "ApplicationPath=%UserProfile%\source\repos\PruttPos\PruttPosSystem\"
CD /D "%ApplicationPath%"
dotnet run
Start "Chrome" Chrome.exe "http://localhost:5000"
pause

Batch-file to update files from SVN and then run a program

Currently am executing a program from command prompt, basically a Python command, but I want that to be automated so that the program runs the latest version of the files before the program starts.
So current program is run by saying:
python c:\program\mysoftwareUI.py
mysoftwareUI.py is present in folder that constantly is provided with updates
Now I want to write a batch file with the above command but before that also SVN command that updates the folder before the actual program is run.
How can I do this?
Create a .bat file script and place it into a directory that is in the PATH variable or the current working directory.
=== doit.bat
#ECHO OFF
PUSHD "c:\program"
svn up
python c:\program\mysoftwareUI.py
POPD
EXIT /B

Batch script command automatically stops batch script

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…

Starting a batch file from another batch file only opens CMD

When I start a batch file from another batch file, it just opens a new CMD window named just "TEST.bat", and doesn't run the actual batch. Running it manually works fine.
cd %~dp0\Colours\TEST.bat
start "TEST.bat"
I have tried many different ways to run the batch, but it all does the same thing. I've also tried to run the batch as administrator but same result again.
Full code(not finished): http://pastebin.com/GE8yJP0J
To run another batch file, use call not start. Also: cd expects a directory, not a filename.
cd "%~dp0\Colours"
call TEST.bat

can't delete folder from batch - folder or file open in another program

done a search on this, but little joy. I am making and later, trying to delete a folder in the same batch file:
mkdir "%_gameKey%"
:: Stuff.....
rmdir /s /q "%_gameKey%"
I get the error "the process cannot access the file because it is being used by another process." I also can't delete the folder via right-click delete - same error. Interestingly, the rmdir removes the contents of the folder. There is nothing in the folder, nor is there anything obvious accessing it.
I have used Unlocker - shows no processes. Have also used Process Explorer, searched on the folder name (with/without full path) - no search results.
When I restart my machine, I can delete it. Not sure if down to user permissions. I see from this that Users only have Read/write not full control. (sorry - not very good with user permissions stuff - especially on windows!). However - surely it can't be this as I can delete it upon restart.
The folder is on a non OS drive.
I'm stumped - any ideas?
A folder cannot be deleted on Windows if any application uses this folder currently as working directory.
In your case I suppose that the batch file uses command cd to change the working directory to the created directory. So you need to use cd once again to set a different working directory before using command rmdir to delete this directory.
It is of course no good idea to start other applications with working directory being currently the directory which should be deleted later and which continue running on exit of batch file as those started applications have this directory as working directory as well.
I had same issue, after launched a powershell process from a folder via win cmd.
After powershell finished, I cd .. in win CMD but rd /q /s gave error: open in another process
I get same error when manually delete folder in explorer window, even if it was empty.
wmic process revealed that powershell.exe could be locking the folder, even though powershell had finished the task & powershell window had closed.
This was confirmed by tasklist
I then taskkill /im powershell.exe, after which the folder could be deleted.
My word - that was an obscure one, but finally found the answer by stepping through the code putting the rmdir in various places. I post this here in case anyone encounters the same...
Basically, I was calling cmd prompts and launching external exe's whilst in the said folder. Later, I was forcibly closing the exe's with TaskKill, but this was leaving the cmd consoles open at the path of the directory I was trying to delete. I'll try be clearer....
Whilst batch script was in the directory (e.g. C:\Windows\Scripts\Launch), I used the following command:
Start "AppLaunch" Call "!_supExe!" !_supCmd!
Which, after expansion, translated to, for e.g.:
Start "AppLaunch" Call "C:\Windows\Program Files(x86)\Troubleshooter\trbshtr.exe" -game "My Game"
I was using this because, from reading, there appears to be a bug in windows making the following command fail:
Start "AppLaunch" "C:\Windows\Program Files(x86)\Troubleshooter\trbshtr.exe" -game "My Game"
The problem comes when you have to use quotes for both the exe and the parameters (for instance where there's spaces). Windows doesn't read it right. Thus had to use topmost to launch these apps.
Problem being, when used:
taskkill /f /im trbshtr.exe
The exe was killed, but the command prompt wasn't. Using /b on the Start command made no difference.
So, the solution was - cd out of the directory into one that the batch script doesn't alter before launching the other apps via the above. Job done....
Now that just leaves me with how to close all those opened cmd windows (or those in taskmgr if I use the /b switch). That's probably a topic for another search or thread!

Resources