'i am facing issue to get bat files logs in jenkins pipeline in running time

I have bat file which are executing in windows server. in the bt file the powershell file is executing and redirecting to output file then that file data is not displaying in jenkins in running time. Here the problem is the output file is printing in console once job is done but not in running time.

cmd /c powershell.exe path\sample.ps > output.txt
@echo
type output.txt
@echo


Solution 1:[1]

Use tee:

tee - read from standard input and write to standard output and files

In below example, running is printed on console before the script's execution is complete. See timestamps in console output for reference.

Execute shell:

cat > script.sh << EOF
echo running | tee log.txt
sleep 30
EOF

chmod +x script.sh
./script.sh

Jenkins Console Output:

17:28:09 + cat
17:28:09 + chmod +x script.sh
17:28:09 + ./script.sh
17:28:09 running
17:28:39 Finished: SUCCESS

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Arun Kumar B