jenkins - Include workspace .log files in "Console Output" -


i have jenkins job executes "foo.sh" , "bar.sh", , scripts produce "foo.log", "bar.log" respectively. foo.sh , bar.sh long running jobs, , wan't view log files unified in "console output" view of jenkins.

i know can archive these logs build artifacts, want monitor 3 logs ("console output"/stdout, foo.log , bar.log) 1 view - console output.

is there plugin or configuration option let me this?


note: foo.sh , bar.sh placeholders, i'm afraid they're vendor , cannot modify them adjust logging behavior.

assume files under $workspace:
tail -f *.log

edit:
or consider re-writing foo.sh , bar.sh, instead of redirecting log file, tee console and log file.

echo "doing stuff" 2>&1|tee -a foo.log
above print console (which displayed in jenkins console output), , redirect foo.log

edit 2:
if have no control on foo.sh , bar.sh, need wrapping script launch them trickery.

basically, after send foo.sh background (so can continue), before tail log, need ensure tail killed. launching background process monitor foo.sh process , kill tail (that yet launched in script). haven't launched tail yet, don't know pid be, hence refer through command line

# send foo.sh background , record pid echo "launching foo.sh background" nohup ./foo.sh & foo_pid=$! echo "foo pid monitor=$foo_pid"  # launch statement run ever 3 seconds monitor status  # of foo.sh, , if foo.sh finished, kill 'future' tail command echo "launching tail-killer background" nohup $(sleep 3; while kill -0 $foo_pid; sleep 3; done; kill $(ps --no-heading -c "tail -f foo.log" | awk '{print $1}') ) &  # tail foo.sh's log echo "launching tail monitor foo.sh" echo tail -f foo.log echo  # return code of foo.sh wait $foo_pid echo "foo.sh returned $? 

considerations/improvements:

  • the "killer" process running every 3 seconds. may want increase performance reasons
  • foo.sh print more 10 lines after start, before tail called. use tail -n increase number of starting lines.
  • the "killer" break if there multiple tail -f foo.log detected. should modify more robust

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -