Node.js Teamcity运行的Grunt未正确输出到日志

Node.js Teamcity运行的Grunt未正确输出到日志,node.js,batch-file,continuous-integration,gruntjs,teamcity,Node.js,Batch File,Continuous Integration,Gruntjs,Teamcity,我有一个teamcity构建,运行grunt作为命令行任务 当我执行grunt default时,输出(在Teamcity日志中)不包含grunt的相关错误输出。但是,它会返回相应的非零退出代码,这会导致teamcity构建正确失败。但是我没有得到grunt错误日志 此页面:介绍我面临的问题的以下解决方法: windows上的Teamcity在退出之前不会刷新标准输出流 grunt节点进程。在这两方面都做了一些工作 点头和咕哝,但这并没有解决。如果你看不见了 在Teamcity构建日志中输出,然

我有一个teamcity构建,运行grunt作为命令行任务

当我执行
grunt default
时,输出(在Teamcity日志中)不包含grunt的相关错误输出。但是,它会返回相应的非零退出代码,这会导致teamcity构建正确失败。但是我没有得到grunt错误日志

此页面:介绍我面临的问题的以下解决方法:

windows上的Teamcity在退出之前不会刷新标准输出流 grunt节点进程。在这两方面都做了一些工作 点头和咕哝,但这并没有解决。如果你看不见了 在Teamcity构建日志中输出,然后尝试运行grunt任务 通过将输出重定向到文件,使用TC命令行运行程序,例如:

grunt default--no color>grunt.tmp&键入grunt.tmp&del grunt.tmp 似乎通过重定向到文件,输出是同步的,而 对于管道(或TC插件执行方法),输出是异步的,而不是 在节点进程退出之前捕获

所以它基本上建议您像这样运行grunt:
grunt default--no color>grunt.tmp&键入grunt.tmp&del grunt.tmp
。然而,这种方法的问题是,它总是返回0(零)作为退出代码,这意味着我的Teamcity构建不会正确地失败


我想这可以通过一些创造性的批处理脚本来解决,但我不知道如何解决这个问题。

谢谢各位,已经更新了自述文件,这会保留grunt调用中正确的退出代码吗?
@echo off

:: prepare environment
setlocal enableextensions
set "tempFile=%temp%\%~nx0.%random%.grunt.tmp"

:: run grunt
call grunt default --no-color > "%tempFile%"

:: Keep the grunt exit code
set "exitCode=%ERRORLEVEL%"

:: Print the grunt output
type "%tempFile%"

:: cleanup and exit with adecuated value
del /q "%tempFile%" >nul 2>nul
endlocal & exit /b %exitCode%
call grunt default --no-color > temp.txt

type temp.txt