Update exisitng view with new jobs

46 views
Skip to first unread message

Siva Reddy

unread,
Nov 13, 2020, 9:46:21 PM11/13/20
to job-dsl-plugin
How to add new jobs to exisitng views, if i use below Script.. everytime it overrides the jobs. But i just want to add new jobs to existing view without removing exisitng ones.


nestedView('project-summary') {
views {
sectionedView('Services') {
filterBuildQueue()
filterExecutors()
sections {
     listView {
          name('PC')
              jobs {
               name('job1')
            }           
    columns {
    status()
    weather()
    name()
    lastSuccess()
    lastFailure()
    }
}
     listView {
          name('POC')
              jobs {
               name('job2')
            }
    columns {
    status()
    weather()
    name()
    lastSuccess()
    lastFailure()
    }
}
}
}
}
}
===========================
this code is adding jobs to only view , but my requirement is it should go inside nested view.



import jenkins.model.Jenkins
import hudson.model.ListView
import hudson.model.View
import hudson.Util;

Jenkins jenkins = Jenkins.getInstance()
jobName = "${params.jobName}"
viewName = "${params.viewName}"

//jenkins.addView(new ListView(viewName))
myView = hudson.model.Hudson.instance.getView(viewName)
for(item in [jobName]) {
    myView.doAddJobToView(item)
}

// save current Jenkins state to disk
jenkins.save()

Reply all
Reply to author
Forward
0 new messages