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

Regression: Job DSL `folder('existing-folder')` creation destroys any views in that folder

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

      This is a regression observed between Jenkins LTS 2.89.4 and LTS 2.107.2.

      The version of the Job DSL plugin (1.69) is unchanged.

      To reproduce:

      1. Run the following Job DSL to create a folder and some sample views within that folder.

      folder('/dir') {
        displayName('dir')
      }
      buildMonitorView('/dir/Test BMV') {
        jobs { regex('.*') }
      }
      listView('/dir/Test LV') {
        jobs { regex(".*") }
      }

      2. Run the following Job DSL script on its own.

      folder('/dir') {
        displayName('dir')
      }

       

      Before the upgrade to Jenkins 2.107.2, this worked fine.  Following the upgrade, step 2 destroys the views that were created in step 1.

          [JENKINS-51035] Regression: Job DSL `folder('existing-folder')` creation destroys any views in that folder

          Apologies, I meant to raise this as a bug originally.  I have now fixed that field.

          Note that we have found it is possible to work around this issue by testing if the directory already exists or not, and only creating if it doesn't, e.g.

            import jenkins.model.Jenkins
            if (!Jenkins.instance.getItem('dir')) ...

          but this is clearly unsatisfactory in the longer term.

          Oliver Lockwood added a comment - Apologies, I meant to raise this as a bug originally.  I have now fixed that field. Note that we have found it is possible to work around this issue by testing if the directory already exists or not, and only creating if it doesn't, e.g.   import jenkins.model.Jenkins   if (!Jenkins.instance.getItem('dir')) ... but this is clearly unsatisfactory in the longer term.

          Aaron D. Marasco added a comment - - edited

          I think importing of previous jobs might be broken - I'm having major problems with environment variables JENKINS-51038

          Aaron D. Marasco added a comment - - edited I think importing of previous jobs might be broken - I'm having major problems with environment variables JENKINS-51038

            daspilker Daniel Spilker
            oliverlockwood Oliver Lockwood
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: