nebffa
nebffa

Reputation: 1549

Create a list view in a subfolder using the job DSL plugin in Jenkins

In Jenkins you can easily create a list view with the Job DSL

listView("myView") {
    jobs {
        regex(".*")
    }
}

but if you try to create a list view within a folder, the folder will be created but not the view

folder("someFolder")

listView("someFolder/myView") {
    jobs {
        regex(".*")
    }
}

Is there a way to accomplish this?

Upvotes: 5

Views: 5907

Answers (2)

nebffa
nebffa

Reputation: 1549

This occurs when a Job DSL performs operations in this order:

  1. Create a folder
  2. Create a view for that folder
  3. Re-create the folder

The reason this happens is that views live in the config file for a folder. When you re-generate a folder, it deletes any configured views for that folder.

To fix this issue in my case, I removed any duplicate folder creation so that each folder was only created once.

Upvotes: 4

Jian
Jian

Reputation: 9

Please use a relative path to create Jobs or pipeline;

jobDsl lookupStrategy: 'SEED_JOB',
    targets: ['src/jobs/**/*.groovy'].join('\n')
  1. Create a folder
  2. Create seed job pipeline in folder
  3. The seed jobs name does not contain the name of the directory

Upvotes: -2

Related Questions