I'm trying DSL job plugin to create new jobs in Jenkins. Is there a way to specify the view when creating the job?
For example, I have a view NewJobsView
. I want to create a DSL job called dsl-job
and it is creating a new job "dsl-created-job1"
DSL like this:
job {
name 'dsl-created-job1'
//view 'NewJobsView'
//or view {...} to specify the view
}
What if you do:
def myJob=job{name('test1')}
def myJob2=job{name('test2')}
view {
name('view1')
jobs{
name(myJob.name)
name(myJob2.name)
}
}
Or even use a regex at the view.
UPDATE
About the discussion. The nested view is just a different kind of view. The job config.xml doesn't have reference to the view because jenkins has a different abstraction: a view references to jobs.
I got this working. It creates a job, then creates a view and adds the job to the view. This solution recreates the view every time. You can add multiple jobs using name('jobname1') or names('jobname1','jobname2'). You can also add existing jobs referencing them by name in the same manner.
job{
name('DSL JOB')
description('This is a Test Job')
triggers{
cron('H/20 7-20 * * 1-5')
}
}
view(type:ListView){
name('DSL-JOBS')
description('Test View of DSL Job')
filterBuildQueue()
filterExecutors()
jobs{
name('DSL JOB')
}
columns{
status()
weather()
name()
lastSuccess()
lastFailure()
lastDuration()
buildButton()
lastBuildConsole()
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With