damianszczepanik / cucumber-reporting-jenkins

Java jenkins plugin for cucumber-jvm reporting
151 stars 12 forks source link

Simultaneous runs of reports run on slaves will occasionally report on the wrong results #91

Closed jhart-r7 closed 10 years ago

jhart-r7 commented 10 years ago

In https://github.com/masterthought/jenkins-cucumber-jvm-reports-plugin-java/blob/master/src/main/java/net/masterthought/jenkins/CucumberReportPublisher.java,

 // if we are on a slave
        if (Computer.currentComputer() instanceof SlaveComputer) {
            listener.getLogger().println("[CucumberReportPublisher] detected this build is running on a slave ");
            FilePath projectWorkspaceOnSlave = build.getProject().getSomeWorkspace();
            FilePath masterJsonReportDirectory = new FilePath(targetBuildDirectory);
            listener.getLogger().println("[CucumberReportPublisher] copying json from: " + projectWorkspaceOnSlave.toURI() + "to reports directory: " + masterJsonReportDirectory.toURI());
            projectWorkspaceOnSlave.copyRecursiveTo("**/*.json", "", masterJsonReportDirectory);

The call to getSomeWorkspace, as documented provides a workspace but not the workspace: http://javadoc.jenkins-ci.org/hudson/model/AbstractProject.html#getSomeWorkspace()

This will result in the wrong JSON data being used if more than one instance of the job is running.

kingsleyh commented 10 years ago

Great explanation of the problem - I'll fix this in the next release

Sent from my iPhone

On 3 Mar 2014, at 18:29, jhart-r7 notifications@github.com wrote:

In https://github.com/masterthought/jenkins-cucumber-jvm-reports-plugin-java/blob/master/src/main/java/net/masterthought/jenkins/CucumberReportPublisher.java,

// if we are on a slave if (Computer.currentComputer() instanceof SlaveComputer) { listener.getLogger().println("[CucumberReportPublisher] detected this build is running on a slave "); FilePath projectWorkspaceOnSlave = build.getProject().getSomeWorkspace(); FilePath masterJsonReportDirectory = new FilePath(targetBuildDirectory); listener.getLogger().println("[CucumberReportPublisher] copying json from: " + projectWorkspaceOnSlave.toURI() + "to reports directory: " + masterJsonReportDirectory.toURI()); projectWorkspaceOnSlave.copyRecursiveTo("*/.json", "", masterJsonReportDirectory); The call to getSomeWorkspace, as documented provides a workspace but not the workspace: http://javadoc.jenkins-ci.org/hudson/model/AbstractProject.html#getSomeWorkspace()

This will result in the wrong JSON data being used.

— Reply to this email directly or view it on GitHub.

jhart-r7 commented 10 years ago

Actually, looking at this now, doesn't this mean that the jsonReportDirectory option is ignored when run on a slave? Regardless of whether or not this runs on a slave, the plugin should pick the correct workspace, it should respect the jsonReportDirectory option and only pick up the files specified or use */.json if none are specified.

kingsleyh commented 10 years ago

I think running on master is fine but on a slave the jsonReportDirectory is ignored - but that's from memory so I might be wrong

Sent from my iPad

On 3 Mar 2014, at 20:42, jhart-r7 notifications@github.com wrote:

Actually, looking at this now, doesn't this mean that the jsonReportDirectory option is ignored? Regardless of whether or not this runs on a slave, the plugin should pick the correct workspace, it should respect the jsonReportDirectory option and only pick up the files specified or use */.json if none are specified.

— Reply to this email directly or view it on GitHub.