Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-71062

Add ability for custom log and report html links

    • Icon: New Feature New Feature
    • Resolution: Won't Do
    • Icon: Minor Minor
    • robot-plugin
    • None

      When running Jenkins in a docker, you will run into an issue when trying to open log.html and report.html file. Both those files are located within the docker container and are not accessible on a browser outside. I suggest adding a "outputlink" option that points to a different url to open these log files.

          [JENKINS-71062] Add ability for custom log and report html links

          Aleksi Simell added a comment -

          Hi,

          As a workaround you can use archiveArtifacts to copy the report and log files from the container to your builtin node (master) and then use the robot plugin normally to have the log files available in Jenkins. Just be sure to have some log retention policy in place, so that your builtin node is not overfilled with old log files.

          Aleksi Simell added a comment - Hi, As a workaround you can use archiveArtifacts to copy the report and log files from the container to your builtin node (master) and then use the robot plugin normally to have the log files available in Jenkins. Just be sure to have some log retention policy in place, so that your builtin node is not overfilled with old log files.

          Sohaib added a comment - - edited

          Thanks for the reply aleksisimell, I am still a novice at Jenkins so can you elaborate how to I can use archiveArtifacts in my situation?

          I use 2 nodes, a master and a slave. I am running Jenkins inside a docker container on port 8080 of my master built with CasC. Our slave is another computer (off the network) that runs our robot files in a specific directory using a declarative pipeline.

          This is in the post section of my pipeline:

          node('slave') {
                  robot( 
                    disableArchiveOutput: false, 
                    outputPath: '/home/user/robot/tests/results', 
                    logFileName: 'log.html', 
                    outputFileName: 'output.xml', 
                    reportFileName: 'report.html', 
                    passThreshold: 100, 
                    unstableThreshold: 90.0
                  )
                }

          Now this stores the log.html and report.html in http://localhost:8080/job/test-robot/1/robot/report/report.html

          If you click the open log.html file it will direct you to a new webpage that calls a GET RESTapi to the link above which of course returns a 404 not found.

          My first question please would be, does archiveArtifacts create a sort of symbolic link to container directory? Is there some sort of backend running in Jenkins that creates this link?

          And second if you don't mind I am also having issues with using the archiveArtifacts command.

          Adding  "archiveArtifacts artifacts: 'build/*.html', fingerprint: true" does not work. And neither does putting the full path to our results directory work. How should I call this command if my results are in say /home/user/robot/tests/results.

          Sohaib added a comment - - edited Thanks for the reply aleksisimell , I am still a novice at Jenkins so can you elaborate how to I can use archiveArtifacts in my situation? I use 2 nodes, a master and a slave. I am running Jenkins inside a docker container on port 8080 of my master built with CasC. Our slave is another computer (off the network) that runs our robot files in a specific directory using a declarative pipeline. This is in the post section of my pipeline: node( 'slave' ) {         robot(            disableArchiveOutput: false ,            outputPath: '/home/user/robot/tests/results' ,            logFileName: 'log.html' ,            outputFileName: 'output.xml' ,            reportFileName: 'report.html' ,            passThreshold: 100,            unstableThreshold: 90.0         )       } Now this stores the log.html and report.html in http://localhost:8080/job/test-robot/1/robot/report/report.html If you click the open log.html file it will direct you to a new webpage that calls a GET RESTapi to the link above which of course returns a 404 not found. My first question please would be, does archiveArtifacts create a sort of symbolic link to container directory? Is there some sort of backend running in Jenkins that creates this link? And second if you don't mind I am also having issues with using the archiveArtifacts command. Adding  "archiveArtifacts artifacts: 'build/*.html', fingerprint: true" does not work. And neither does putting the full path to our results directory work. How should I call this command if my results are in say /home/user/robot/tests/results.

          Sohaib added a comment - - edited

          After spending some time I understand my problem. Archive artifacts can only find files within the current workspace, you cannot use an external directory. Once I added

          sh "cp /home/user/robot/tests/results/*.html $WORKSPACE"

          And I was able to see the archived artifacts with a simple

          archiveArtifacts artifacts: '*', fingerprint: true 

          But there are two things to note:
          1. Opening the robot links to log.html and report.html still fails. You will need to click the archive artifacts link that appears instead.
          2. I got an "Error: Opening Robot Framework log failed", and found a solution here.

          I still think adding a custom redirect link is important to have. We can even leverage the User Content feature for this.

          But this is still better than having an Nginx server running scanning for files. Thanks aleksisimell for the help!

           

           

          Sohaib added a comment - - edited After spending some time I understand my problem. Archive artifacts can only find files within the current workspace, you cannot use an external directory. Once I added sh "cp /home/user/robot/tests/results/*.html $WORKSPACE" And I was able to see the archived artifacts with a simple archiveArtifacts artifacts: '*' , fingerprint: true But there are two things to note: 1. Opening the robot links to log.html and report.html still fails. You will need to click the archive artifacts link that appears instead. 2. I got an "Error: Opening Robot Framework log failed", and found a solution here . I still think adding a custom redirect link is important to have. We can even leverage the User Content feature for this. But this is still better than having an Nginx server running scanning for files. Thanks aleksisimell for the help!    

          Aleksi Simell added a comment -

          Hi,

          Sorry for the delay in answering. Failing to open log and report files is a known feature and is explained in the plugin documentation. Allowing the opening of external files inside Jenkins is against default Jenkins policies and could potentially expose your Jenkins instance to security vulnerabilities. Hence, we have decided not to do anything about that and just document how you can change your CSP settings yourself.

          Good that you managed to archive your log files. As a short explanation, you run your builds in your slave machine, so your log files are there as well (not in your master). If you want to have the log files available in master after the build, you need to archive them in your slave. Your snippet is a valid archiveArtifacts, although "*" is quite a broad achive and I would narrow that down to just your test output.

           

          Aleksi Simell added a comment - Hi, Sorry for the delay in answering. Failing to open log and report files is a known  feature and is explained in the plugin documentation . Allowing the opening of external files inside Jenkins is against default Jenkins policies and could potentially expose your Jenkins instance to security vulnerabilities. Hence, we have decided not to do anything about that and just document how you can change your CSP settings yourself. Good that you managed to archive your log files. As a short explanation, you run your builds in your slave machine, so your log files are there as well (not in your master). If you want to have the log files available in master after the build, you need to archive them in your slave. Your snippet is a valid archiveArtifacts, although "*" is quite a broad achive and I would narrow that down to just your test output.  

          Sohaib added a comment -

          Makes sense, thanks again. You can close this issue if it does not seem necessary to add custom links.

          Sohaib added a comment - Makes sense, thanks again. You can close this issue if it does not seem necessary to add custom links.

          Aleksi Simell added a comment -

          Closing as allowing external files to be opened is a documented security issue.

          Aleksi Simell added a comment - Closing as allowing external files to be opened is a documented security issue.

            aleksisimell Aleksi Simell
            sohmahmood Sohaib
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: