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

Unable to use *Publish HTML Reports* with pytest-html

      When attempting to build a HTML Report using pytest-html, the file is created in this path`file:///opt/repos/<git branch>/htmlreports/pytest-output.html`. However htmlpublisher is not correctly archiving it. With the console output indicating the results below.

      [htmlpublisher] Archiving at BUILD level /var/jenkins_home/workspace/<Jenkins project> to /var/jenkins_home/jobs/<Jenkins project>/builds/10/htmlreports/pytest-output
      

       

          [JENKINS-63488] Unable to use *Publish HTML Reports* with pytest-html

          I'd have to see what settings you are using for the HTML Publisher config but as a general rule, you should have the files that you want to publish in the workspace directory.

          Richard Bywater added a comment - I'd have to see what settings you are using for the HTML Publisher config but as a general rule, you should have the files that you want to publish in the workspace directory.

          S R added a comment -

           

          I've included the relevant shell script being used as well as the plugin settings. The JUnit plugin seems to be able to respond well to this shell script, but the same code doesn't seem to work for the html plugin. Unfortunately since the html plugin supports more robust data, I'm stuck with using it.

          In the script, the file gets created in docker. I then copy the file to a new folder in what I'm guessing is the Jenkins workspace. From what I've seen so far it looks like the plugin expects a folder to exist and automatically uses the `Report Title` setting to do this. If no title is given, then it seems to use the file name as that new folder.

          # copy report files from container to jenkins
          CONTAINER_ID=$(docker ps -a --filter ancestor=$APP:$TAG -q | head -1)
          docker cp "$CONTAINER_ID:/opt/repos/locus-web-dry-lab/pytest-report.xml" .
          .mkdir -p './htmlreport' && \ 
              docker cp "$CONTAINER_ID:/opt/repos/locus-web-dry-lab/pytest-report.html" "./htmlreport/pytest-report.html"
          

          S R added a comment -   I've included the relevant shell script being used as well as the plugin settings. The JUnit plugin seems to be able to respond well to this shell script, but the same code doesn't seem to work for the html plugin. Unfortunately since the html plugin supports more robust data, I'm stuck with using it. In the script, the file gets created in docker. I then copy the file to a new folder in what I'm guessing is the Jenkins workspace. From what I've seen so far it looks like the plugin expects a folder to exist and automatically uses the `Report Title` setting to do this. If no title is given, then it seems to use the file name as that new folder. # copy report files from container to jenkins CONTAINER_ID=$(docker ps -a --filter ancestor=$APP:$TAG -q | head -1) docker cp "$CONTAINER_ID:/opt/repos/locus-web-dry-lab/pytest-report.xml" . .mkdir -p './htmlreport' && \ docker cp "$CONTAINER_ID:/opt/repos/locus-web-dry-lab/pytest-report.html" "./htmlreport/pytest-report.html"

          Thanks srisom - I think I see the issue and why it isn't working for you. It's true that the report title is used for the folder to publish to but it isn't used with where to pull from. I think (I don't have a chance to double check at the moment) that what you want is to set 'HTML directory to archive' to `htmlreport`. Index page should be all good because that index page is at the top level of the directory you are setting to be archived. Report title can be changed if you want to anything that will be meaningful to the user as its used on the menu UI for the project/jobs.

          If you want to give that a go and if its still not working share what is being seen now that's probably the best next step.

          Richard Bywater added a comment - Thanks srisom - I think I see the issue and why it isn't working for you. It's true that the report title is used for the folder to publish to but it isn't used with where to pull from . I think (I don't have a chance to double check at the moment) that what you want is to set 'HTML directory to archive' to `htmlreport`. Index page should be all good because that index page is at the top level of the directory you are setting to be archived. Report title can be changed if you want to anything that will be meaningful to the user as its used on the menu UI for the project/jobs. If you want to give that a go and if its still not working share what is being seen now that's probably the best next step.

            r2b2_nz Richard Bywater
            srisom S R
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: