Interview Prep/Jenkins/Platform: plugins, JCasC & Kubernetes agents

A Job DSL seed in JCasC should create a folder per team from a YAML list. How do you structure it?

IntermediateScenarioPlatform: plugins, JCasC & Kubernetes agents
Answer

Situation read → Data-driven job generation.

What I'd do →

  1. Store teams.yaml in the platform repo, mounted into the controller.
  2. Job DSL script:
    def teams = new org.yaml.snakeyaml.Yaml().load(readFileFromWorkspace('teams.yaml'))
    teams.each { t ->
      folder(t.name) { displayName(t.display) }
      organizationFolder("${t.name}/repos") { /* github org config */ }
    }
    
    (When run from JCasC, read the file with plain Groovy new File('/var/jenkins_config/teams.yaml').text.)
  3. Apply folder permissions and credentials per team in the same script.

Why → Adding a team is a one-line YAML change reviewed in Git.

Interview tip → Mention Job DSL's removedJobAction for cleaning up deleted teams.

All Jenkins questions Roadmap: Jenkins

More on Platform: plugins, JCasC & Kubernetes agents