Roman Rdgz
Roman Rdgz

Reputation: 13254

Redirecting shell output in Jenkins to a file

I have a job in jenkins which executes many python scripts in a shell:

#!/bin/bash -x
mkdir -p $WORKSPACE/validation/regression
rm -f $WORKSPACE/validation/regression/*.latest

cd $WORKSPACE/PythonTests/src/
# Execute test cases
python tests.py 031 > $WORKSPACE/validation/regression/TP031output_b$BUILD_NUMBER.log
python tests.py 052 > $WORKSPACE/validation/regression/TP052output_b$BUILD_NUMBER.log
python tests.py 060 > $WORKSPACE/validation/regression/TP060output_b$BUILD_NUMBER.log

My intention is that each script output (which I can see in my terminal if I execute them manually) is stored in a log file with that classic redirection.

It used to work, but now it just creates an empty file. I can't find out what has changed since then.

Any hint?

Upvotes: 2

Views: 6394

Answers (1)

user8512189
user8512189

Reputation:

This worked for me in Jenkins Build execute shell:

[command] 2>&1 | tee [outputfile]

Upvotes: 2

Related Questions