Search code examples
jenkinsjenkins-pluginsjenkins-job-dsl

create dsl job inside a job


When I run the job I should create a freestyle job with a parameter name and repo.

I already try this but it doesn't work.

 freeStyleJob('seed') {
    parameters {
      stringParam("GITHUB_REPO_NAME", "", "repo_name")
      stringParam("JOB_NAME", "", "name for the job")
    }
    steps {
      dsl {
        job('\$DISPLAY_NAME') {

        }
      }
    }
  }

Solution

  • You can create a job inside a job by using 'text': https://jenkinsci.github.io/job-dsl-plugin/#path/freeStyleJob-steps-dsl-text

    steps {
      dsl {
        text('job ("name") {}')
      }
    }