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

Promotions aren't copies when job generated with DSL

      Sample DSL:

      freeStyleJob('test1') {
        properties {
          promotions {
            promotion {
              name('promotion 1')
              icon('Silver white star')
              conditions {
                manual('admin')
              }
              actions {
                shell "echo test"
              }
            }
          }
        }
      }
      
      freeStyleJob('test2') {
        using('test1')
      }
      

      test1 is built fine
      XML for test2:

      <?xml version="1.0" encoding="UTF-8"?><project>
          <actions/>
          <description/>
          <keepDependencies>false</keepDependencies>
          <properties>
              <hudson.plugins.promoted__builds.JobPropertyImpl plugin="promoted-builds@2.28">
                  <activeProcessNames>
                      <string>promotion 1</string>
                  </activeProcessNames>
              </hudson.plugins.promoted__builds.JobPropertyImpl>
          </properties>
          <scm class="hudson.scm.NullSCM"/>
          <canRoam>true</canRoam>
          <disabled>false</disabled>
          <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
          <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
          <triggers/>
          <concurrentBuild>false</concurrentBuild>
          <builders/>
          <publishers/>
          <buildWrappers/>
      </project>
      

      however, no promotions:

      # ls test2/promotions/ | wc -l
      0
      

          [JENKINS-41029] Promotions aren't copies when job generated with DSL

          Seems that the issue is with the construction of the

          JobPropertyImpl

          in the jobDsl contect, the class is initiated and a call is made to

          setOwner

          which, in turn, runs

          loadChildren

          .
          Problem is, in this context, the root dir, is now the NEW job, not the old one, so, the class isn't initiated properly and thus, later, the List of

          processes

          is left empty.
          I think, that also, part of the problem, is that in no entry point between the jobDsl plugin code, to the promotion one, I have see any reference that passes the name of the template job, which makes it impossibly to load it from the right context.
          Solution would be either:

          1. pass
            dslItem

            on

            javaposse/jobdsl/plugin/JenkinsJobManagement.class:492

            (or anywhere else before so, like, in the initialisation if the

            JobPropertyImpl
          2. Change the Promotion plugin to NOT use subfolders and have all the context in the original XML of the job

          Elad Shmitanka added a comment - Seems that the issue is with the construction of the JobPropertyImpl in the jobDsl contect, the class is initiated and a call is made to setOwner which, in turn, runs loadChildren . Problem is, in this context, the root dir, is now the NEW job, not the old one, so, the class isn't initiated properly and thus, later, the List of processes is left empty. I think, that also, part of the problem, is that in no entry point between the jobDsl plugin code, to the promotion one, I have see any reference that passes the name of the template job, which makes it impossibly to load it from the right context. Solution would be either: pass dslItem on javaposse/jobdsl/plugin/JenkinsJobManagement. class: 492 (or anywhere else before so, like, in the initialisation if the JobPropertyImpl Change the Promotion plugin to NOT use subfolders and have all the context in the original XML of the job

            jamietanna Jamie Tanna
            shimitanaka Elad Shmitanka
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: