Search code examples
loggingjenkinscontinuous-integrationhudsonarchiving

How to organize log files from Jenkins builds?


Currently I have a Jenkins job with console output that I would like to save to separate log files. I already know how to create the log files with UNIX commands, but I'm trying to figure out the best way to organize these files. Does Jenkins provide any sort of "universal" build number? I could use the $BUILD_NUMBER and $BUILD_TAG-$BUILD_ID, though I figured a hash or some other sort of label would be more durable. (What happens if past builds get deleted?)

I could also label the log files based on the timestamp the Jenkins build was kicked off, but I'm unsure of how accurate it would be. Does Jenkins record a "master time" for when a build starts/ends?

Other suggestions would be greatly appreciated, as well. How do you store your Jenkins log files?


Solution

  • I think $BUILD_TAG should be good enough, it's usually like "Jenkins-$JOB_NAME-$BUILD_NUMBER", of course you could append the UNIX timestamp to make it more unique, so it would become something like Jenkins-$JOB_NAME-$BUILD_NUMBER-1234567890.

    To answer your 2 questions specifically :

    1. Does Jenkins provide any sort of "universal" build number?

      It is incremental automatically (still increase even if you delete the past builds) unless you reset it, so it could be regarded as universal in my opinion.

    2. Does Jenkins record a "master time" for when a build starts/ends?

      Jenkins records the build start time, you can find it in the build history.