jenkinshyperlinkjenkins-pipelinejenkins-groovyfile-link

Display a file path as hyperlink from archive after jenkins build


I have a pipeline job in Jenkins. Once it finishes , it archives some files. I need to display a particular file from the archived folder. Example file is D:/1234/errorLog.txt If job is failed , this path should be provided in the email. How can I achieve this ? It should be able to access that folder from email, by clicking that link.


Solution

  • All files that are archived can be accessed via the Jenkins URL. So, for example if I had an archived errorLog.txt, I would be able to access it like this:

    JENKINS_URL/job/JOB_NAME/BUILD_NUMBER/artifact/path/to/file/errorLog.txt
    

    So if you were sending an email, the email would have to contain the formatted string with the Jenkins URL, Job name, and build number set.

    You can also do this with folders. If you were to go to the artifacts root folder:

    JENKINS_URL/job/JOB_NAME/BUILD_NUMBER/artifact
    

    You would see the archived folders listed out:

    archive tree

    So anyone clicking on the list would have the page open up in their browser.