I have a multiline batch script in one of my steps that kicks off a build process. Problem is, the jom.exe creates another shell prompt where you don't see any of the output of in real-time on Jenkins. Is there a way to redirect output? Here is the snippet of the area in question:
stage('Build') {
steps {
bat """
echo ${BUILD_DIR}
call "${VCVARSALL}\\vcvars64.bat"
IF EXIST "%BUILD_DIR%" (
rmdir "%BUILD_DIR%" /s /q
)
mkdir "%BUILD_DIR%"
cd "%BUILD_DIR%"
start "" /WAIT "${QT_HOME}\\qmake.exe" ..\\FFF.pro -spec win32-msvc "CONFIG+=debug" "CONFIG+=qml_debug"
start "" /WAIT "${JOM_HOME}\\jom.exe" -j 8 -f Makefile.Debug"
"""
}
}
Thanks to the comments I managed to fix this by removing the random quote and removing the start "" /WAIT
Related
I'm trying to execute a batch file but its console is not stopping for its output.
here's the code:
goto D:
cd postgresql-9.6.0-1-windows-x64-binaries
cd pgsql
cd bin
start pg_ctl start -D D:\pg_data\data
#echo on
echo server started
pause
I am assuming it is on the D: drive. use cd /d see cd /? for the reason why.
#echo off
cd /d "D:\postgresql-9.6.0-1-windows-x64-binaries\pgsql\bin"
start "" "pg_ctl" start -D "D:\pg_data\data"
echo server started
pause
change to start "" /wait if you want to wait for the service to start before you echo it has been started.
Cd /d "D:\Test"
START mvn clean install -DskipTests
xcopy /s "D:\Test\brsint-web\brsint-webapp\target\Test.war" "D:\apache-tomcat-7.0_1.2Latest (2)\webapps" /Y
Cd /d "D:\apache-tomcat-7.0_1.2Latest (2)\bin"
START startup.bat
I am trying to write a bat file which has series of actions I wanted to perform. I want to trigger 3rd line after 2nd line execution. 2nd line is a maven build which generates war file it takes time to complete. Mean while 3rd line i.e., copy command is getting executed before War file is generated. Please help me resolve.
Trying to maintain the structure you had as best as possible, I would suggest perhaps this:
CD /D "D:\Test"
(Call mvn clean install -DskipTests) || GoTo :EOF
XCopy "D:\Test\brsint-web\brsint-webapp\target\Test.war" "D:\apache-tomcat-7.0_1.2Latest (2)\webapps" /S /Y
CD "D:\apache-tomcat-7.0_1.2Latest (2)\bin"
Call "startup.bat"
If the mvn command is not successful the script will end at that point!
You can use the /Wait or /W flag after the Start Command. This will spawn the process and wait for a Return or Exit code before continuing.
e.g.
Cd /d "D:\Test"
START /wait mvn clean install -DskipTests
xcopy /s "D:\Test\brsint-web\brsint-webapp\target\Test.war" "D:\apache-tomcat-7.0_1.2Latest (2)\webapps" /Y
Cd /d "D:\apache-tomcat-7.0_1.2Latest (2)\bin"
START /wait startup.bat
So...I have "launcher"..
Its .bat file and i want it to start /ffa/server.exe
but..In ffa/ i have config file.
When i start server via launcher it starts server but it makes new config file
in directory of launcher..How can i fix this?
And "server" its: https://github.com/OgarProject/Ogar
start cmd /k %~dp0\ffa\server.exe
Please help me, its really frustrating..Thanks <3!
You can use pushd to move to the correct directory, start the server, and then pop back:
pushd %~dp0\ffa
start cmd /k server.exe
popd
I'm not familiar with the exact folder structure you're working with, and exactly how you call the script, but you definitely could use push/popd for this.
There are more possible solutions to change working directory of started command prompt window:
In calling script
pushd %~dp0\ffa
start "" cmd /k server.exe
popd
In started cmd itself: note properly escaped & character (see redirection)
start "" cmd /k pushd %~dp0\ffa^&server.exe
Using /D parameter of start command
start "" /D "%~dp0\ffa" cmd /k server.exe
I'm attempting to use Batch for the first time, and I'm running into some trouble with the timeout command. I'm making a simple backup program to backup certain files to my flash drive, and this is the beginning.I'm trying to make it so that the prompt does not show how much of the countdown is left. This is what I have:
ECHO Deleting current backup location...
RD /s /q F:\CurrentBackup
#TIMEOUT /t 10
ECHO Setting up new backup...
MKDIR F:\CurrentBackup
MKDIR F:\CurrentBackup\Documents
MKDIR F:\CurrentBackup\Pictures
MKDIR F:\CurrentBackup\Desktop
MKDIR F:\CurrentBackup\Music
rem xcopy C:\Eric D:\
Can anyone help me with this seemingly simple problem?
you can tell a command, where to write it's output. If you don't, it writes it to screen
TIMEOUT /t 10 >nul
will write the output to a "Null-Device" (also known as "Nirwana")
by the way: # does not suppress the output of a command, but suppress the repetition of the commandline. It's a kind of "one-line-echo off"
Normally, you put
#echo off
as the first line of a script.
echo off will turn command repetition off, and the # does the same thing for this very line (as the echo off is not yet active for this line)
I tested the folowing lines in cmd ("ctrl + r" ---> "cmd")
and it works fine , but it doensn't work in .bat file , cmd comes up and then instantly closes
Here is my code
D:
cd D:\Java\Projects\Jasper\random-jasper-lib\
mvn clean install
cd D:\Java\Projects\Jasper\random-jasper\
mvn clean install
pause
How can I get the window to Stay open ?? (preferably even if there are errors)
mvn is a batch file.
If you call one batchfile from another, you have to use call otherwise the calling batch file will be terminated:
Using the /d for the cd command is also a good idea.
cd /d D:\Java\Projects\Jasper\random-jasper-lib\
call mvn clean install
cd /d D:\Java\Projects\Jasper\random-jasper\
call mvn clean install
pause
Why not with the pause command? -alternatively put cmd /k on the very last line of your script.
cd /d "D:\Java\Projects\Jasper\random-jasper-lib"
start /b "" "mvn" clean install
cd /d "D:\Java\Projects\Jasper\random-jasper"
start /b "" "mvn" clean install
cmd /k
try it like this:
PUSHD D:\Java\Projects\Jasper\random-jasper-lib\
mvn clean install
POPD
PUSHD D:\Java\Projects\Jasper\random-jasper\
mvn clean install
POPD
PAUSE
save as test.bat and execute it from cmd. that way it won't close the shell and you can see the errormessages