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

Unable to copy the sloccount summary when the job has been executed on a slave with a different OS

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Blocker
    • Resolution: Fixed
    • sloccount-plugin
    • None
    • I had the issue when running the master on Windows XP and executing the Job on Unix (Ubuntu Server)

    Description

      If I execute my job on a slave that runs on Unix, when the master node that runs on Windows XP tries to copy the file sloccount.sc from the slave to the master jobs directory I get the following exception (it results to a build failure).

       
      java.io.IOException: remote file operation failed: C:\var\jenkins\workspace\sloccount-fasttrack\sloccount.sc at hudson.remoting.Channel@11a5ec7:AES-KLBUILD
      	at hudson.FilePath.act(FilePath.java:910)
      	at hudson.FilePath.act(FilePath.java:887)
      	at hudson.FilePath.copyTo(FilePath.java:1809)
      	at hudson.plugins.sloccount.SloccountPublisher.copyFilesToBuildDirectory(SloccountPublisher.java:139)
      	at hudson.plugins.sloccount.SloccountPublisher.perform(SloccountPublisher.java:92)
      	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:784)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:756)
      	at hudson.model.Build$BuildExecution.post2(Build.java:183)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:705)
      	at hudson.model.Run.execute(Run.java:1695)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      	at hudson.model.ResourceController.execute(ResourceController.java:88)
      	at hudson.model.Executor.run(Executor.java:231)
      Caused by: java.io.FileNotFoundException: C:\var\jenkins\workspace\sloccount-fasttrack\sloccount.sc (No such file or directory)
      	at java.io.FileInputStream.open(Native Method)
      	at java.io.FileInputStream.<init>(FileInputStream.java:138)
      	at hudson.FilePath$37.invoke(FilePath.java:1814)
      	at hudson.FilePath$37.invoke(FilePath.java:1809)
      	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2461)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:118)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
      	at hudson.remoting.Request$2.run(Request.java:328)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:724)
      Build step 'Publish SLOCCount analysis results' marked build as failure}}
      

      As you can see, the master starts to get crazy because in copyFilesToBuildDirectory, it uses the sourceFile.getAbsolutePath(). This method tries to resolve the sourceFile against the current JVM FileSystem that is different from the slave.

      BTW, I am wondering why the code uses the getAbsolutePath() method instead of the getPath() that returns the actual file path.

      Attachments

        Activity

          poussma Mathieu POUSSE created issue -
          poussma Mathieu POUSSE added a comment - - edited

          Should be fixed with https://github.com/jenkinsci/sloccount-plugin/pull/27
          Waiting for the merge of the pull request as I am not granted to do so.

          poussma Mathieu POUSSE added a comment - - edited Should be fixed with https://github.com/jenkinsci/sloccount-plugin/pull/27 Waiting for the merge of the pull request as I am not granted to do so.

          Need to be tested with a master running on Unix
          Waiting for the merge of the pull request https://github.com/jenkinsci/sloccount-plugin/pull/27

          poussma Mathieu POUSSE added a comment - Need to be tested with a master running on Unix Waiting for the merge of the pull request https://github.com/jenkinsci/sloccount-plugin/pull/27
          poussma Mathieu POUSSE made changes -
          Field Original Value New Value
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]
          mixalturek Michal Turek added a comment -

          Hi Mathieu,

          thank you for the bug report and the patch, it was my fault :-/

          I would suggest to evaluate the path on slave side (which should be safer) instead of on master, the related code is in class SloccountPublisherReport. We can transform sourceFiles member to List<FileNamePath>, where FileNamePath is a custom structure with two strings initialized to getName() and getAbsolutePath(). What do you think?

          I will have time to look at it and release a new version at the end of this week at the earliest. I can test only Linux to Linux case.

          Let's have the task opened until a new version is released, it disappeared from the list referenced by wiki.

          Michal

          mixalturek Michal Turek added a comment - Hi Mathieu, thank you for the bug report and the patch, it was my fault :-/ I would suggest to evaluate the path on slave side (which should be safer) instead of on master, the related code is in class SloccountPublisherReport. We can transform sourceFiles member to List<FileNamePath>, where FileNamePath is a custom structure with two strings initialized to getName() and getAbsolutePath(). What do you think? I will have time to look at it and release a new version at the end of this week at the earliest. I can test only Linux to Linux case. Let's have the task opened until a new version is released, it disappeared from the list referenced by wiki. Michal
          mixalturek Michal Turek made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]

          Code changed in jenkins
          User: mathieu-pousse
          Path:
          src/main/java/hudson/plugins/sloccount/SloccountPublisher.java
          http://jenkins-ci.org/commit/sloccount-plugin/db4e6b3d365158fbc150bba1fc6d66878bde0770
          Log:
          Fix for JENKINS-21467. Tries to revert the file name for the original file system

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: mathieu-pousse Path: src/main/java/hudson/plugins/sloccount/SloccountPublisher.java http://jenkins-ci.org/commit/sloccount-plugin/db4e6b3d365158fbc150bba1fc6d66878bde0770 Log: Fix for JENKINS-21467 . Tries to revert the file name for the original file system

          Code changed in jenkins
          User: Michal Turek
          Path:
          src/main/java/hudson/plugins/sloccount/SloccountPublisher.java
          http://jenkins-ci.org/commit/sloccount-plugin/2e8cb21bcfabbf442a7f5f3ce332ae79c40d3d2f
          Log:
          Merge pull request #27 from mathieu-pousse/master

          [FIXED JENKINS-21467]. Tries to revert the file name for the original ...

          Compare: https://github.com/jenkinsci/sloccount-plugin/compare/e09bf66bbf62...2e8cb21bcfab

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Michal Turek Path: src/main/java/hudson/plugins/sloccount/SloccountPublisher.java http://jenkins-ci.org/commit/sloccount-plugin/2e8cb21bcfabbf442a7f5f3ce332ae79c40d3d2f Log: Merge pull request #27 from mathieu-pousse/master [FIXED JENKINS-21467] . Tries to revert the file name for the original ... Compare: https://github.com/jenkinsci/sloccount-plugin/compare/e09bf66bbf62...2e8cb21bcfab
          scm_issue_link SCM/JIRA link daemon made changes -
          Resolution Fixed [ 1 ]
          Status Reopened [ 4 ] Resolved [ 5 ]

          Code changed in jenkins
          User: Michal Turek
          Path:
          src/main/java/hudson/plugins/sloccount/SloccountPublisher.java
          src/main/java/hudson/plugins/sloccount/model/SloccountPublisherReport.java
          http://jenkins-ci.org/commit/sloccount-plugin/e55f588ed9746f73c7cb1f82b54c6b55ef16c3be
          Log:
          JENKINS-21467 Unable to copy the sloccount summary when the job has been executed on a slave with a different OS

          • Previous code change that tries to evaluate the path on master machine removed.
          • The code now evaluates the path on slave which is much more robust. The master receives only two strings with file name and absolute path relative to slave machine.
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Michal Turek Path: src/main/java/hudson/plugins/sloccount/SloccountPublisher.java src/main/java/hudson/plugins/sloccount/model/SloccountPublisherReport.java http://jenkins-ci.org/commit/sloccount-plugin/e55f588ed9746f73c7cb1f82b54c6b55ef16c3be Log: JENKINS-21467 Unable to copy the sloccount summary when the job has been executed on a slave with a different OS Previous code change that tries to evaluate the path on master machine removed. The code now evaluates the path on slave which is much more robust. The master receives only two strings with file name and absolute path relative to slave machine.
          mixalturek Michal Turek made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          mixalturek Michal Turek added a comment -

          Fixed in 1.13.

          mixalturek Michal Turek added a comment - Fixed in 1.13.
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 153333 ] JNJira + In-Review [ 207353 ]

          People

            poussma Mathieu POUSSE
            poussma Mathieu POUSSE
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: