Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a timeout between two batch command lines in Jenkins

Tags:

This is the code I want to launch with Jenkins :

start cmd.exe /k "node "C:\Program Files\Appium\node_modules\appium\bin\appium.js" -a 127.0.0.1 -p 4723" ping 127.0.0.1 -n 30 > nul C:\path\NUnit-2.6.4\NUnit-2.6.4\bin\nunit-console.exe C:\path\NUnit-2.6.4\NUnit-2.6.4\bin\apk\UnitTestProject1.dll 

This is the error I get every time I try to put a pause:

"ERROR: Input redirection is not supported, exiting the process immediately." 

Same error with timeout /T 60 and sleep 60

According to this post , timeout does not work in non-interactive scripts.

How can I add a pause in my situation ?

Edit for Will Ryan :

I try this :

enter image description here

The build worked, but the test duration is only 0.5 seconds, the pause doesn't do anything

enter image description here

The console output is :

C:\Program Files\Jenkins\jobs\ZFAIL\workspace>echo "--"  "--"  C:\Program Files\Jenkins\jobs\ZFAIL\workspace>PING 1.1.1.1 -n 1 -w 30000  1>NUL   C:\Program Files\Jenkins\jobs\ZFAIL\workspace>echo "++"  "++"  C:\Program Files\Jenkins\jobs\ZFAIL\workspace>exit 0  Finished: SUCCESS 
like image 569
CE_ Avatar asked Aug 31 '15 09:08

CE_


People also ask

How do I create a timeout in a batch file?

Timeout with the parameter /NOBREAK If we take the example from before and run that in a BATCH file: timeout /t 60 then while waiting those 60 seconds, you are actually able to break the timeout by pressing any key on your keyboard. To prevent this we simply add the parameter /NOBREAK to the end of it.

How do you pause 10 seconds in a batch file?

You can insert the pause command before a section of the batch file that you might not want to process. When pause suspends processing of the batch program, you can press CTRL+C and then press Y to stop the batch program.

How do I add a delay in a batch file?

Type in your command.TIMEOUT — Type timeout time where "time" is replaced by the number of seconds to delay. For example, typing in timeout 30 will delay your batch file for 30 seconds.

How do I change the sleep time in a batch file?

The correct way to sleep in a batch file is to use the timeout command, introduced in Windows 2000.


2 Answers

I think you can use the following command in Execute Windows batch command (will wait for 100 seconds):

waitfor SomethingThatIsNeverHappening /t 100  

This will return an error which could break your build. To avoid that, redirect the error output:

waitfor SomethingThatIsNeverHappening /t 100 2>NUL 
like image 181
Yauheni Basalai Avatar answered Sep 17 '22 15:09

Yauheni Basalai


You can use this:

PING 1.1.1.1 -n 1 -w 30000 >NUL 

This send one ping attempt and waits 30 seconds for a response. Not sure why you're getting the "ERROR: Input redirection is not supported, exiting the process immediately." message but I actively use the command above regularly.

like image 24
Will Ryan Avatar answered Sep 21 '22 15:09

Will Ryan