After a bit more of a play around I have identified a workaround, but ultimately it was down to unexpected behaviour by both Jenkins and JMeter.
Firstly, Jenkins was not creating a new workspace for every build and was not clearing down the workspace after each build. This meant that all existing artefacts were still present from previous builds when new builds were being started.
Secondly, when starting up, JMeter simply apends to any existing log file instead of creating it from scratch.
The combination of the 2 meant that the results.csv file on the Jenkins runner was what contained all previous run data, not the perfReport plugin. The perfReport plugin appeared to be doing everything correctly.
I have now added a cleardown section to my jenkins file and everything looks good.
However I did notice that in failed or unstable builds, the graphs were not being populated. This appears to be caused by these conditions causing the plugin to fail before generating the reports. A quick fix for this was to have 2 perfReport entries in your stage. 1 that creates the reports then 1 that processes the pass criteria.
stage('Publish report') {
perfReport 'result.csv'
perfReport sourceDataFiles: 'result.csv',
filterRegex: '',
failBuildIfNoResultFile: true,
errorFailedThreshold: 5,
errorUnstableThreshold: 1
}
If anyone has a better solution to this final issue, I am all ears but happy with the way it is running now.