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

multiple jobDSL() pipeline steps destroys all but the last

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • job-dsl-plugin
    • None

      If you use the pipeline step jobDsl() twice or if you use the "Process job DSL" build step in the GUI only your last step works.

      This destroys anything in the earlier steps.

      Example. Given two jobDSL sections with the following jobDSL:

      folder('zz-folder1')
      job('zz-folder1/job-one')
      
      folder('zz-folder2')
      job('zz-folder2/job-two')
      

      You then get this as the output:

      Processing provided DSL script
      Added items:
          GeneratedJob{name='zz-folder1'}
          GeneratedJob{name='zz-folder1/job-one'}
      Unreferenced items:
          GeneratedJob{name='zz-tron'}
          GeneratedJob{name='zz-tron2'}
      
      Processing provided DSL script
      Added items:
          GeneratedJob{name='zz-folder2'}
          GeneratedJob{name='zz-folder2/job-two'}
      Unreferenced items:
          GeneratedJob{name='zz-folder1'}
          GeneratedJob{name='zz-folder1/job-one'}
      Removed items:
          GeneratedJob{name='zz-folder1'}
      
      Finished: SUCCESS
      

      If you want to set different actions (e.g. DELETE vs. DISABLE) or "ignore changes" then you're going to have a bad day as all but your last jobs get deleted.

            daspilker Daniel Spilker
            docwhat Christian Höltje
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: