vbscript - Jenkins not reading ERRORLEVEL -


i testing simple build process in jenkins; build section has execute windows batch command

echo %errorlevel% cscript c:\users\user\documents\test.vbs echo %errorlevel% 

my test.vbs nothing except set errorlevel environment variable; tried using wscript.quit see if had effect on errorlevel

dim wshell dim wsysenv  set wshell = wscript.createobject("wscript.shell") set wsysenv = wshell.environment("system")  wscript.echo "errorlevel=" & wsysenv( "errorlevel" ) wsysenv( "errorlevel" ) = 0 wscript.echo "errorlevel=" & wsysenv( "errorlevel" ) wsysenv( "errorlevel" ) = 2 wscript.echo "errorlevel=" & wsysenv( "errorlevel" ) wscript.quit 3 

there no post build action console output follows:

started user anonymous building in workspace c:\program files (x86)\jenkins\jobs\tads host-agent client\workspace [workspace] $ cmd /c call c:\users\user\appdata\local\temp\hudson4571524647235360597.bat  c:\program files (x86)\jenkins\jobs\tads host-agent client\workspace>echo 1  1  c:\program files (x86)\jenkins\jobs\tads host-agent client\workspace>cscript c:\users\user\documents\test.vbs  microsoft (r) windows script host version 5.8 copyright (c) microsoft corporation. rights reserved.  errorlevel=0 errorlevel=0 errorlevel=2  c:\program files (x86)\jenkins\jobs\tads host-agent client\workspace>echo 1  1  c:\program files (x86)\jenkins\jobs\tads host-agent client\workspace>exit 1  build step 'execute windows batch command' marked build failure finished: failure 

as shown in output above, errorlevel before start script 1. script sets errorlevel 2 , exits code of 3. when check errorlevel @ end of script, 1 started.

i found pages said environment variables set current process , child process; session environment variables.

in case how can errorlevel set jenkins report test success or failure? doesn't appear check variable during runtime, @ start of execution of script. not useful script may change value of variable.

%errorlevel% automatic variable, , shouldn't tamper directly, more since write-access system environment requires admin privileges.

%errorlevel% should automatically populated integer value passed quit method. vbscript line wscript.quit 3 called batch script this:

@echo off echo %errorlevel% cscript //nologo c:\path\to\your.vbs echo %errorlevel% 

should produce following output:

c:\>c:\path\to\your.cmd 0 3

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -