Answers: <p>I would recommend cleaning the workspace on each run, this should ensure you're not running into old files in the workspace. You'll want to run this as a post build step, meaning it runs regardless of the build status.</p>
  <p>There's a pretty decent thread here too for a more detailed explanation when it comes to declarative and the Workspace Cleanup <a href="https://plugins.jenkins.io/ws-cleanup/" rel="nofollow noreferrer">plugin</a>:</p>
  <pre><code>pipeline {
      agent any
      stages {
          stage('Example') {
              steps {
                  echo 'Hello World'
              }
          }
      }
      post { 
          always { 
              cleanWs()
          }
      }
  }
  </code></pre>
  <p><a href="https://stackoverflow.com/questions/37468455/jenkins-pipeline-wipe-out-workspace">https://stackoverflow.com/questions/37468455/jenkins-pipeline-wipe-out-workspace</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2022-01-25T23:22:12.207Z
Answers: 2022-01-25T23:22:12.207Z
Answers: casey vega
Body: <p>I'm trying to get our test reports (generated using google test with the xml output switch) into Jenkins, but keep getting the error message:</p>
  
  <p><code>Test reports were found but none of them are new. Did leafNodes run?</code></p>
  
  <p>Jenkins says the test xml files are 15s old, which means these must have been generated on this test run.</p>
  
  <p>We're using a declarative pipeline, and the TEST stage looks like:</p>
  
  <pre class="lang-java prettyprint-override"><code>stage("TEST") {
    steps {
      dir("${BUILD_ROOT}") {
        sh "make test_report_clean test || true"
        junit keepLongStdio: true, testResults: '*_test_gcov.xml'
      }
    }
  }
  </code></pre>
  
  <p>Here the <code>test_report_clean</code> make target deletes any existing xml reports, and the <code>test</code> target is generated from cmake's <code>add_test</code> function. I have verified that test reports are being generated in the correct location by looking in the Jenkins workspace.</p>
  
  <p>I've also tried the xunit plugin, but the same error message is produced!</p>
  
  <p>(This question was originally posted to Super User but I was asked to move it.)</p>
  
Comments: CC BY-SA 4.0
Comments: 2020-02-25T21:22:14.730Z
Comments: I just ran into this for the past while, for me the issue was I wasn't deleting my old tests as I I thought I was. I even got files 19 seconds old once, so I also figured that it must be from that run. junit has a timeout of 3 seconds: https://github.com/jenkinsci/junit-plugin/blob/master/src/main/java/hudson/tasks/junit/TestResult.java#L205  Not sure if this is your issue, good luck.
Comments: mtfurlan
Tags: <jenkins>
Title: Jenkins error using Junit plugin: Test reports were found but none of them are new. Did LeafNodes run?
UserDisplayName: Mike Knee
ThreadText: # Jenkins error using Junit plugin: Test reports were found but none of them are new. Did LeafNodes run?
  
  (Asked by: username_0 on 2019-10-18)
  
  I'm trying to get our test reports (generated using google test with the xml output switch) into Jenkins, but keep getting the error message:
  
  `Test reports were found but none of them are new. Did leafNodes run?`
  
  Jenkins says the test xml files are 15s old, which means these must have been generated on this test run.
  
  We're using a declarative pipeline, and the TEST stage looks like:
  
  ```java
  stage("TEST") {
    steps {
      dir("${BUILD_ROOT}") {
        sh "make test_report_clean test || true"
        junit keepLongStdio: true, testResults: '*_test_gcov.xml'
      }
    }
  }
  
  ```
  
  Here the `test_report_clean` make target deletes any existing xml reports, and the `test` target is generated from cmake's `add_test` function. I have verified that test reports are being generated in the correct location by looking in the Jenkins workspace.
  
  I've also tried the xunit plugin, but the same error message is produced!
  
  (This question was originally posted to Super User but I was asked to move it.)
  
  **Tags:** jenkins
  
  > **Comments:**
  > **username_1**: I just ran into this for the past while, for me the issue was I wasn't deleting my old tests as I I thought I was. I even got files 19 seconds old once, so I also figured that it must be from that run. junit has a timeout of 3 seconds: https://github.com/jenkinsci/junit-plugin/blob/master/src/main/java/hudson/tasks/junit/TestResult.java#L205  Not sure if this is your issue, good luck.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2022-01-25. Score: 0
  
  I would recommend cleaning the workspace on each run, this should ensure you're not running into old files in the workspace. You'll want to run this as a post build step, meaning it runs regardless of the build status.
  
  There's a pretty decent thread here too for a more detailed explanation when it comes to declarative and the Workspace Cleanup [plugin](https://plugins.jenkins.io/ws-cleanup/):
  
  ```
  pipeline {
      agent any
      stages {
          stage('Example') {
              steps {
                  echo 'Hello World'
              }
          }
      }
      post { 
          always { 
              cleanWs()
          }
      }
  }
  
  ```
  
  <https://stackoverflow.com/questions/37468455/jenkins-pipeline-wipe-out-workspace>
  
  
  ---
  
  