Issue
In a pipeline script i am able to get a view in the public area of jenkins like this
println Jenkins.get().getView("TECHNICAL") // => hudson.model.AllView@787d286c[view/TECHNICAL/]
But I need one of the views in "My views", the path of that view in the browser is "http://servername:8080/user/myusername/my-views/view/Overview/"
The following doesn't work:
println Jenkins.get().getView("/user/myusername/my-views/view/Overview") // => null
How can I open a view in My views ?
Solution
User views are part of User object embedded in UserProperties
. Please check the following script
script {
def username = 'admin'
def user = User.get(username, false, null)
if (user != null) {
for(def property: user.getAllProperties()) {
if(property instanceof hudson.model.MyViewsProperty) {
for(def view : property.getViews()){
println(view.name)
}
}
}
}
}
Answered By - ycr
Answer Checked By - Mary Flores (JavaFixing Volunteer)