diff --git a/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java b/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java index 224fc8dd7..2640b50a5 100644 --- a/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java +++ b/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java @@ -1345,7 +1345,9 @@ public static final class CustomJenkinsRule extends JenkinsRule implements AutoC public CustomJenkinsRule(URL url) throws Exception { this.jenkins = Jenkins.get(); this.url = url; - jenkins.setNoUsageStatistics(true); // cannot use JenkinsRule._configureJenkinsForTest earlier because it tries to save config before loaded + if (jenkins.isUsageStatisticsCollected()) { + jenkins.setNoUsageStatistics(true); // cannot use JenkinsRule._configureJenkinsForTest earlier because it tries to save config before loaded + } if (JenkinsLocationConfiguration.get().getUrl() == null) { JenkinsLocationConfiguration.get().setUrl(url.toExternalForm()); }