Larry Cai
Larry Cai

Reputation: 59933

How can I get the joblist in jenkins after I execute the jobdsl

How can I get the job list in jenkins after I execute the jobdsl ?

Jenkin JobDSL is nice to manage the jenkins jobs. When you execute the jobDSL, jenkins can help to generate the jobs are expected. Even more, if the job is created, you can choose to skip or overwrite.

Now I want to trigger the build directly after it is new generated.

See sample console output from jenkins build.

Processing DSL script demoJob.groovy
Added items:
GeneratedJob{name='simpliest-job-ever'}
Existing items:
    GeneratedJob{name=’existing-job'}

How can I get the jobname simpliest-job-ever in jenkins? And in this case, I don't want to build existing-job

Scan the console log could be choice, but it is not elegant enough.

Upvotes: 1

Views: 718

Answers (1)

daspilker
daspilker

Reputation: 8194

You can trigger a build from the DSL script using the queue method (docs).

job('simpliest-job-ever') {
  // ...
}

queue('simpliest-job-ever')

Upvotes: 3

Related Questions