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

absolute path (with folders) throws exception

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Using absolute path like

      Project Name = /folder/job1

      results in:

      FATAL: com.cloudbees.hudson.plugins.folder.Folder cannot be cast to hudson.model.Job
      java.lang.ClassCastException: com.cloudbees.hudson.plugins.folder.Folder cannot be cast to hudson.model.Job
      	at hudson.plugins.copyartifact.CopyArtifact$EnvAction.getProject(CopyArtifact.java:471)
      	at hudson.plugins.copyartifact.CopyArtifact$EnvAction.add(CopyArtifact.java:450)
      	at hudson.plugins.copyartifact.CopyArtifact$EnvAction.access$400(CopyArtifact.java:444)
      	at hudson.plugins.copyartifact.CopyArtifact.perform(CopyArtifact.java:267)
      	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:802)
      	at hudson.model.Build$BuildExecution.build(Build.java:199)
      	at hudson.model.Build$BuildExecution.doRun(Build.java:160)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:584)
      	at hudson.model.Run.execute(Run.java:1575)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      	at hudson.model.ResourceController.execute(ResourceController.java:88)
      	at hudson.model.Executor.run(Executor.java:237)
      
      

        Attachments

          Activity

          Hide
          kellys Kelly Schoenhofen added a comment - - edited

          We're experiencing the same issue since we upgraded to Jenkins 1.509.31 & Folders 3.14 & Folders Plus 1.8. I can't seem to find a work-around that works for us - if we're trying to copy artifacts from the workspace of the last successful build of a different project that ran on another build node, I'm not sure how I can set an absolute path.

          Say the complete tree that I want to get artifacts from is:
          http://jenkins/job/Top/job/Middle/job/BottomA/
          I'm currently here:
          http://jenkins/job/Top/job/Middle/job/BottomB/

          Under "Copy Artifacts From Another Project" we had:
          "BottomA" entered, and "Copy from WORKSPACE of latest completed build".

          We got the exception above (about not being able to cast to hudson.model.Job).
          I changed it to "/Top/Middle/BottomA" and it still errored.

          Any ideas? If not, is there a version we can fall back to?

          UPDATE: It was the next copy artifact task that was failing; it was "TopC/MiddleC/BottomC" and I put a / in front of it and now we're working. Thanks!

          Show
          kellys Kelly Schoenhofen added a comment - - edited We're experiencing the same issue since we upgraded to Jenkins 1.509.31 & Folders 3.14 & Folders Plus 1.8. I can't seem to find a work-around that works for us - if we're trying to copy artifacts from the workspace of the last successful build of a different project that ran on another build node, I'm not sure how I can set an absolute path. Say the complete tree that I want to get artifacts from is: http://jenkins/job/Top/job/Middle/job/BottomA/ I'm currently here: http://jenkins/job/Top/job/Middle/job/BottomB/ Under "Copy Artifacts From Another Project" we had: "BottomA" entered, and "Copy from WORKSPACE of latest completed build". We got the exception above (about not being able to cast to hudson.model.Job). I changed it to "/Top/Middle/BottomA" and it still errored. Any ideas? If not, is there a version we can fall back to? UPDATE: It was the next copy artifact task that was failing; it was "TopC/MiddleC/BottomC" and I put a / in front of it and now we're working. Thanks!
          Hide
          ndeloof Nicolas De Loof added a comment -

          @jesse remember the "projectName" may include parmeters or matrix-axe as last part, as it uses "/" separator for this. So can't just use Jenkins.getInstance().getItemByFullName(jobName, Job.class), need to lookup each subelement up to first Job instance

          Show
          ndeloof Nicolas De Loof added a comment - @jesse remember the "projectName" may include parmeters or matrix-axe as last part, as it uses "/" separator for this. So can't just use Jenkins.getInstance().getItemByFullName(jobName, Job.class), need to lookup each subelement up to first Job instance
          Hide
          ndeloof Nicolas De Loof added a comment -

          So, as a resume, this issue is "foo" MAY be considered equivalent to "/foo" when used from a Folder. Looks buggy to me, and will break if you later create a "foo" item inside folder, but can understand the backward compatibility issue.

          Show
          ndeloof Nicolas De Loof added a comment - So, as a resume, this issue is "foo" MAY be considered equivalent to "/foo" when used from a Folder. Looks buggy to me, and will break if you later create a "foo" item inside folder, but can understand the backward compatibility issue.
          Hide
          jglick Jesse Glick added a comment -

          the "projectName" may include parmeters or matrix-axe as last part, as it uses "/" separator for this

          Since 6243f6b (JENKINS-13222) in 1.26, parameters are in a separate field. Matrix axes are still in the project field, but that is fine because getItemByFullName works for that.

          Show
          jglick Jesse Glick added a comment - the "projectName" may include parmeters or matrix-axe as last part, as it uses "/" separator for this Since 6243f6b ( JENKINS-13222 ) in 1.26, parameters are in a separate field. Matrix axes are still in the project field, but that is fine because getItemByFullName works for that.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Nicolas De Loof
          Path:
          src/main/java/hudson/plugins/copyartifact/CopyArtifact.java
          src/test/java/hudson/plugins/copyartifact/CopyArtifactTest.java
          http://jenkins-ci.org/commit/copyartifact-plugin/5153c276e923ea7e0fd73ab9a7adacad4261c4ba
          Log:
          [FIXED JENKINS-19833] support (mostly) absolute path for job name
          i.e. job name can be fully qualified but not start with "/"
          required for backward compatibility

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: src/main/java/hudson/plugins/copyartifact/CopyArtifact.java src/test/java/hudson/plugins/copyartifact/CopyArtifactTest.java http://jenkins-ci.org/commit/copyartifact-plugin/5153c276e923ea7e0fd73ab9a7adacad4261c4ba Log: [FIXED JENKINS-19833] support (mostly) absolute path for job name i.e. job name can be fully qualified but not start with "/" required for backward compatibility

            People

            • Assignee:
              ndeloof Nicolas De Loof
              Reporter:
              mattsheehan Matt Sheehan
            • Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: