0

I have a Jenkins multibranch pipeline which is polling periodically my svn for new commits. Running the pipeline, multiple log files are created which are saved in workspace directory (which will be cleaned for each new pipeline build). To save them durably I want to move the files to the builds directory of Jenkins where all build specific jenkins-logs, etc. are saved too. The default path in my file directory is:

...\${JENKINS_HOME}\jobs\*name-multibranch-job*\branches\*a-cryptic-name*\builds\*build-number*\

This path is specified in the file ...\${JENKINS_HOME}\config.xml as

<hudson>
    ...
    <buildsDir>${ITEM_ROOTDIR}/builds</buildsDir>
    ...
</hudson>

How can I access this value in my Pipeline script to move my log files via robocopy? The variables ${ITEM_ROOTDIR} and ${ITEM_FULL_NAME} (see https://wiki.jenkins.io/display/JENKINS/Features+controlled+by+system+properties) are e.g. not recognized in pipeline script:

No such property: ITEM_FULL_NAME for class: WorkflowScript
j_d
  • 19
  • 1
  • 7

1 Answers1

2

Your log files, or any other files you might want to access later, are "build artifacts". You should point them out to Jenkins, e.g. like this:

     sh "echo 1 > my.1.log"
     sh "echo 2 > my.2.log"
     sh "echo 3 > my.3.log"
     archiveArtifacts allowEmptyArchive: true,
       artifacts: '*.log',
       caseSensitive: false, 
       defaultExcludes: false, 
       onlyIfSuccessful: false

These will be viewable in your specific build view, and will be deleted together with the build.

MaratC
  • 6,418
  • 2
  • 20
  • 27