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

MultiJobBuild.SubBuild does not contain full job name (if using folders)

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • multijob-plugin
    • None

      When using the MultiJob plugin with the CloudBees folder plugin, the MultiJobBuild.SubBuild class contains only the short job name. For example if we have 'MultiJobA' which runs job 'FolderFoo/JobB' as subtask, the info about the build does not contain 'FolderFoo/JobB' but only 'JobB' (the contained URL is fine). Thus, there is no easy way to understand which JobB was executed.

        1. jenkins-multijob-plugin.hpi
          112 kB
        2. build.png
          build.png
          4 kB
        3. screenshot-1.png
          screenshot-1.png
          17 kB

          [JENKINS-30906] MultiJobBuild.SubBuild does not contain full job name (if using folders)

          Vasili Galka added a comment - - edited

          hagzag Haggai, any chance you can take a look on this? Many thanks! Vasili

          Vasili Galka added a comment - - edited hagzag Haggai, any chance you can take a look on this? Many thanks! Vasili

          hagzag added a comment -

          itai / itaior -> I took a look and didn't quite get how we get the folder name ... we should discuss this today looks like a small fix no ?

          hagzag added a comment - itai / itaior -> I took a look and didn't quite get how we get the folder name ... we should discuss this today looks like a small fix no ?

          Vasili Galka added a comment -

          hagzag As far as I know, project.getFullName() gives the full path e.g. FooFolder/BarFolder/JobA

          Vasili Galka added a comment - hagzag As far as I know, project.getFullName() gives the full path e.g. FooFolder/BarFolder/JobA

          Chen Cohen added a comment -

          Trying to understand this issue I created the following structure (see screenshot-1)
          Where exactly do you expect to see 'folder1/job1', is it in this view?
          Please elaborate.
          Thanks, Chen.

          Chen Cohen added a comment - Trying to understand this issue I created the following structure (see screenshot-1) Where exactly do you expect to see 'folder1/job1', is it in this view? Please elaborate. Thanks, Chen.

          Vasili Galka added a comment -

          Hi Chen,
          No, I don't refer to the project class. I have mentioned the MultiJobBuild.SubBuild class. It contains info about specific build that took place, like #123 you know... See the attached picture. The code building this page has no simple way to know the job was Foo/SvnUpdate.
          Best, Vasili

          Vasili Galka added a comment - Hi Chen, No, I don't refer to the project class. I have mentioned the MultiJobBuild.SubBuild class. It contains info about specific build that took place, like #123 you know... See the attached picture. The code building this page has no simple way to know the job was Foo/SvnUpdate. Best, Vasili

          hagzag added a comment -

          hi vvv444, chenc & I discussed and I have to say we didn't understand the issue yet ...
          Is it the display name of the job when you are in the context of a folder, is it the link to the specific job or maybe a third option you might have described and we both didn't understand yet ...

          Pending you input.
          HP

          hagzag added a comment - hi vvv444 , chenc & I discussed and I have to say we didn't understand the issue yet ... Is it the display name of the job when you are in the context of a folder, is it the link to the specific job or maybe a third option you might have described and we both didn't understand yet ... Pending you input. HP

          Vasili Galka added a comment - - edited

          Hi hagzag,

          My apologies for unclear explanation. Let me explain in more detail:

          Say we have the following job configuration:

          MultiJob1
              Phase1
                 MyFolder/Job1
          

          Suppose this job was executed and it resulted in build MultiJob1 #1 which in turn executed build MyFolder/Job1 #5.

          Now, say we write some Java/Groovy code that needs to access this information. For instance, in my specific case I was designing some Email generating code. The code has reference to MultiJobBuild object describing MultiJob1 #1:

          MultiJobBuild build1;
          SubBuild subBuild = build1.getBuilders().get(0);
          // subBuild.getBuildNumber() is 5
          // subBuild.getJobName() is "Job1"
          // There is no "MyFolder/Job1" info in the subBuild object.
          

          I want to obtain AbstractBuild object describing MyFolder/Job1 #5 basing on the information in subBuild. But how can I do it? As far as I understand there is no enough info for that in the SubBuild object.

          Best,
          Vasili

          Vasili Galka added a comment - - edited Hi hagzag , My apologies for unclear explanation. Let me explain in more detail: Say we have the following job configuration: MultiJob1 Phase1 MyFolder/Job1 Suppose this job was executed and it resulted in build MultiJob1 #1 which in turn executed build MyFolder/Job1 #5 . Now, say we write some Java/Groovy code that needs to access this information. For instance, in my specific case I was designing some Email generating code. The code has reference to MultiJobBuild object describing MultiJob1 #1 : MultiJobBuild build1; SubBuild subBuild = build1.getBuilders().get(0); // subBuild.getBuildNumber() is 5 // subBuild.getJobName() is "Job1" // There is no "MyFolder/Job1" info in the subBuild object. I want to obtain AbstractBuild object describing MyFolder/Job1 #5 basing on the information in subBuild. But how can I do it? As far as I understand there is no enough info for that in the SubBuild object. Best, Vasili

          Chen Cohen added a comment -

          Hi Vasili and thanks for your detailed explanation.

          Since MultiJobBuild is sub-type of AbstractBuild you can use the following:

          MultiJobBuild mjb;
          mjb.getProject().getFullName();
          

          When debugging the example in screenshot-1.png the above code returns: folder1/job1
          Please let me know if it worked for you.

          Thanks,
          Chen

          Chen Cohen added a comment - Hi Vasili and thanks for your detailed explanation. Since MultiJobBuild is sub-type of AbstractBuild you can use the following: MultiJobBuild mjb; mjb.getProject().getFullName(); When debugging the example in screenshot-1.png the above code returns: folder1/job1 Please let me know if it worked for you. Thanks, Chen

          Vasili Galka added a comment -

          Hi chenc,

          But my question was, how do I get the mjb corresponding to the subBuild?

          Best,
          Vasili

          Vasili Galka added a comment - Hi chenc , But my question was, how do I get the mjb corresponding to the subBuild? Best, Vasili

          Chen Cohen added a comment -

          Hi Vasili,

          MultiJobBuild.SubBuild is not aware of its container. You can't do that.

          Regards,
          Chen

          Chen Cohen added a comment - Hi Vasili, MultiJobBuild.SubBuild is not aware of its container. You can't do that. Regards, Chen

          Vasili Galka added a comment -

          Hi Chen,

          I'm not interested in the container. I'm interested in the AbstractBuild corresponding to the SubBuild (the sub-job that was executed).

          Regards,
          Vasili

          Vasili Galka added a comment - Hi Chen, I'm not interested in the container. I'm interested in the AbstractBuild corresponding to the SubBuild (the sub-job that was executed). Regards, Vasili

          Chen Cohen added a comment -

          Hi Vasili,

          I've added AbstractBuild to SubBuild, so you can call SubBuild.getBuild to get the data you requested. I've uploaded a locally build hpi that I was hoping you can try and confirm that it solves this issue.
          Please let me know how it worked.

          Thanks,
          Chen.

          Chen Cohen added a comment - Hi Vasili, I've added AbstractBuild to SubBuild, so you can call SubBuild.getBuild to get the data you requested. I've uploaded a locally build hpi that I was hoping you can try and confirm that it solves this issue. Please let me know how it worked. Thanks, Chen.

          Code changed in jenkins
          User: Haggai Philip Zagury
          Path:
          src/main/java/com/tikal/jenkins/plugins/multijob/MultiJobBuilder.java
          src/main/java/com/tikal/jenkins/plugins/multijob/StatusJob.java
          http://jenkins-ci.org/commit/tikal-multijob-plugin/170e19a30b422cd445334edd29918277da298eb7
          Log:
          Fix JENKINS-30906 -> Restore build on scm changes logic

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Haggai Philip Zagury Path: src/main/java/com/tikal/jenkins/plugins/multijob/MultiJobBuilder.java src/main/java/com/tikal/jenkins/plugins/multijob/StatusJob.java http://jenkins-ci.org/commit/tikal-multijob-plugin/170e19a30b422cd445334edd29918277da298eb7 Log: Fix JENKINS-30906 -> Restore build on scm changes logic

          Code changed in jenkins
          User: Haggai Philip Zagury
          Path:
          src/main/java/com/tikal/jenkins/plugins/multijob/MultiJobBuilder.java
          src/main/java/com/tikal/jenkins/plugins/multijob/StatusJob.java
          http://jenkins-ci.org/commit/tikal-multijob-plugin/0c815f76b66fc532e7585c6a801cd4fcbeb161ce
          Log:
          Merge pull request #76 from hagzag/master

          Fix JENKINS-30906 -> Restore build on scm changes logic

          Compare: https://github.com/jenkinsci/tikal-multijob-plugin/compare/34eeddd1c4d3...0c815f76b66f

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Haggai Philip Zagury Path: src/main/java/com/tikal/jenkins/plugins/multijob/MultiJobBuilder.java src/main/java/com/tikal/jenkins/plugins/multijob/StatusJob.java http://jenkins-ci.org/commit/tikal-multijob-plugin/0c815f76b66fc532e7585c6a801cd4fcbeb161ce Log: Merge pull request #76 from hagzag/master Fix JENKINS-30906 -> Restore build on scm changes logic Compare: https://github.com/jenkinsci/tikal-multijob-plugin/compare/34eeddd1c4d3...0c815f76b66f

          Code changed in jenkins
          User: Chen Cohen
          Path:
          src/main/java/com/tikal/jenkins/plugins/multijob/MultiJobBuild.java
          src/main/java/com/tikal/jenkins/plugins/multijob/MultiJobBuilder.java
          http://jenkins-ci.org/commit/tikal-multijob-plugin/67e0633fad2789a1c4dc89cd76beef6166addf68
          Log:
          fix JENKINS-30906

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Chen Cohen Path: src/main/java/com/tikal/jenkins/plugins/multijob/MultiJobBuild.java src/main/java/com/tikal/jenkins/plugins/multijob/MultiJobBuilder.java http://jenkins-ci.org/commit/tikal-multijob-plugin/67e0633fad2789a1c4dc89cd76beef6166addf68 Log: fix JENKINS-30906

          Code changed in jenkins
          User: Haggai Philip Zagury
          Path:
          src/main/java/com/tikal/jenkins/plugins/multijob/MultiJobBuild.java
          src/main/java/com/tikal/jenkins/plugins/multijob/MultiJobBuilder.java
          http://jenkins-ci.org/commit/tikal-multijob-plugin/ec5919885e001c4aa8d6baa8c8687d1252a979a0
          Log:
          Merge pull request #80 from cohencil/master

          Fix JENKINS-30906 - Add support for Full job name via API

          Compare: https://github.com/jenkinsci/tikal-multijob-plugin/compare/6b4fe28c649c...ec5919885e00

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Haggai Philip Zagury Path: src/main/java/com/tikal/jenkins/plugins/multijob/MultiJobBuild.java src/main/java/com/tikal/jenkins/plugins/multijob/MultiJobBuilder.java http://jenkins-ci.org/commit/tikal-multijob-plugin/ec5919885e001c4aa8d6baa8c8687d1252a979a0 Log: Merge pull request #80 from cohencil/master Fix JENKINS-30906 - Add support for Full job name via API Compare: https://github.com/jenkinsci/tikal-multijob-plugin/compare/6b4fe28c649c...ec5919885e00

          Chen Cohen added a comment -

          Added AbstractBuild to SubBuild. See PR #80

          Chen Cohen added a comment - Added AbstractBuild to SubBuild. See PR #80

            chenc Chen Cohen
            vvv444 Vasili Galka
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: