Create a DSL job that creates a new job in the same view

I am trying to create a DSL plugin to create new jobs in Jenkins. Is there a way to specify a view when creating a task?

For example, I have a view NewJobsView. I want to create a DSL job called dsl-joband it creates a new job "dsl-created-job1"

DSL:

job {
    name 'dsl-created-job1'
    //view 'NewJobsView'
    //or view {...} to specify the view
}
+3
source share
3 answers

What to do, if:

def myJob=job{name('test1')}
def myJob2=job{name('test2')}
view {
  name('view1')
  jobs{
     name(myJob.name)
    name(myJob2.name)
  }   
}

Or even use a regular expression in the view.

UPDATE

About the discussion. A nested view is just another view. There is no reference to the view in the config.xml job because jenkins has another abstraction: the view refers to the jobs.

+3
source

. , . . , ('jobname1') ('jobname1', 'jobname2'). , .

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()
    }
}
+1

, , :

:

  • , DSL
  • ( ) DSL
  • , ,
  • create a new empty task with the same name as the new generated task from DSL.
  • check Add to current view when saving a new empty job
  • run the DSL script and it will update the existing (empty) task with the correct contents, leaving it in the right form.

You can also check this answer.

0
source

All Articles