Jenkins “Console Output” log location in filesystem

后端 未结 8 2409
自闭症患者
自闭症患者 2020-12-13 12:56

I want to access and grep Jenkins Console Output as a post build step in the same job that creates this output. Redirecting logs with >> log.txt is not a

相关标签:
8条回答
  • 2020-12-13 13:32

    I found the console output of my job in the browser at the following location:

    http://[Jenkins URL]/job/[Job Name]/default/[Build Number]/console

    0 讨论(0)
  • 2020-12-13 13:34

    Jenkins stores the console log on master. If you want programmatic access to the log, and you are running on master, you can access the log that Jenkins already has, without copying it to the artifacts or having to GET the http job URL.

    From http://javadoc.jenkins.io/archive/jenkins-1.651/hudson/model/Run.html#getLogFile(), this returns the File object for the console output (in the jenkins file system, this is the "log" file in the build output directory).

    In my case, we use a chained (child) job to do parsing and analysis on a parent job's build.

    When using a groovy script run in Jenkins, you get an object named "build" for the run. We use this to get the http://javadoc.jenkins.io/archive/jenkins-1.651/hudson/model/Build.html for the upstream job, then call this job's .getLogFile().

    Added bonus; since it's just a File object, we call .getParent() to get the folder where Jenkins stores build collateral (like test xmls, environment variables, and other things that may not be explicitly exposed through the artifacts) which we can also parse.

    Double added bonus; we also use matrix jobs. This sometimes makes inferring the file path on the system a pain. .getLogFile().getParent() takes away all the pain.

    0 讨论(0)
提交回复
热议问题