• Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • job-dsl-plugin
    • None

      I was hoping that

                          jobDsl targets: ['jobs/*.groovy', 'config-files/*.groovy', 'views/*.groovy'].join('\n'),
                              removedJobAction: 'DELETE',
                              removedViewAction: 'DELETE',
                              removedConfigFilesAction: 'DELETE',
                              lookupStrategy: 'JENKINS_ROOT',
                              unstableOnDeprecation: true,
                              failOnMissingPlugin: true
      

      would also delete all jobs not managed by job-dsl - unfortunate its not. If job-dsl would have an option to remove everything it does not know about (jobs, configFiles, views) then keeping the environment cleaner would be a lot easier. Our organization could define a rule saying: 'all our items must be created via job-dsl and be reproducible everything else will be deleted.

      Therefore I ask for a feature to enforce job-dsl to only keep items it knows about.

          [JENKINS-54878] remove items not managed by job-dsl

          You could potentially use something like:

           

          toBeRemoved = Jenkins.instance.items.findAll{!it.getActions(javaposse.jobdsl.plugin.actions.SeedJobAction.class)}
          toBeRemoved.each{ println "${it} would be removed..."}
          
          /// toBeRemoved.each{ item.delete()} 
          /// Jenkins.instance.save()
          
          println 'done'

          Victor Martinez added a comment - You could potentially use something like:   toBeRemoved = Jenkins.instance.items.findAll{!it.getActions(javaposse.jobdsl.plugin.actions.SeedJobAction.class)} toBeRemoved.each{ println "${it} would be removed..." } /// toBeRemoved.each{ item.delete()} /// Jenkins.instance.save() println 'done'

            jamietanna Jamie Tanna
            imod Dominik Bartholdi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: