11

I'm trying to put jobs inside a folder using jenkins DSL script Now i create a listView and i put inside my jobs here the code i'm using

listView('MyJobsList') {
  jobs {
     map.each{
       name((it.key).trim())
     }
  }
   columns{
        status()
        weather()
        name()
        lastSuccess()
        lastFailure()
        lastDuration()
        buildButton()
    }
}

i want to do the same thing but this time i want to put the jobs in a folder !!

Ibtissam
  • 509
  • 3
  • 8
  • 21

2 Answers2

16

Please refer the below Job-DSL documentation to create a folder in Jenkins through Job-DSL.

Folder

folder('folder-a') {
    description('Folder containing all jobs for folder-a')
}
job('folder-a/job-a') {
    // Job config goes here
}
Suresh
  • 730
  • 1
  • 5
  • 12
  • 1
    This is completely incorrect for modern versions of Jenkins. – christopher Sep 25 '20 at 12:23
  • 4
    @christopher can you explain what is wrong with it? This answer matches the current job DSL documentation here: https://github.com/jenkinsci/job-dsl-plugin/wiki/Job-DSL-Commands "Items can be created within folders by using the full path as job name." – IanAWP Nov 26 '20 at 09:30
0

Please, take a look at Jenkins filestructure: https://wiki.jenkins-ci.org/display/JENKINS/Administering+Jenkins

Here you can see where jobs are stored by default (job config and build logs). You can not and should not change this filestructure with DSL script (JobDSL plugin).

Olia
  • 815
  • 4
  • 16