You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a view contains regular expression control characters, such as () view.exists?('snap (build)') and transitively view.list_jobs(('snap (build)') will not work.
e.g. here's a list
I, [2017-04-25T11:31:06.175580 #27075] INFO -- : Obtaining views based on filter ''
D, [2017-04-25T11:31:06.175721 #27075] DEBUG -- : GET /api/json?tree=views[name]
D, [2017-04-25T11:31:06.262497 #27075] DEBUG -- : HTTP Code: 200, Response Body: {"_class":"hudson.model.Hudson","views":[{"_class":"hudson.model.ListView","name":"0 release ☉"},{"_class":"hudson.model.ListView","name":"1 stable ⚛ git stable"},{"_class":"hudson.model.ListView","name":"2 unstable ☣ git master"},{"_class":"hudson.plugins.status_view.StatusView","name":"3 red ⚕"},{"_class":"hudson.model.ListView","name":"4 release LTS ◎"},{"_class":"hudson.plugins.view.dashboard.Dashboard","name":"dash"},{"_class":"hudson.model.ListView","name":"iso"},{"_class":"hudson.model.ListView","name":"mergers"},{"_class":"hudson.model.ListView","name":"mgmt"},{"_class":"hudson.model.ListView","name":"plasma"},{"_class":"hudson.model.ListView","name":"qt"},{"_class":"hudson.plugins.view.dashboard.Dashboard","name":"snap (build)"},{"_class":"hudson.plugins.status_view.StatusView","name":"stable_plasma (red)"},{"_class":"hudson.plugins.status_view.StatusView","name":"testy"},{"_class":"hudson.model.ListView","name":"watcher"}]}
It does contain {"_class":"hudson.plugins.view.dashboard.Dashboard","name":"snap (build)"}. Yet calling view.list_jobs('snap (build)') will result in an exception being raised RuntimeError: The view snap (build) doesn't exists on the server.
Reason being #list_jobs internally does the following
raise "The view #{view_name} doesn't exists on the server"\
unless exists?(view_name)
#exists? in turn calls
list(view_name).include?(view_name)
and in #list the view_name is then interpolated into a regex
view_names << view["name"] if view["name"] =~ /#{filter}/i
at this point the "filter" (which was our view_name) will produce a bogus regex as we'll effectively have /snap (build)/i which isn't at all what the initial method call of #list_jobs wanted.
To fix this exists?(x) should probably be
def exists?(view_name)
list.include?(view_name)
end
The text was updated successfully, but these errors were encountered:
If a view contains regular expression control characters, such as ()
view.exists?('snap (build)')
and transitivelyview.list_jobs(('snap (build)')
will not work.e.g. here's a list
It does contain
{"_class":"hudson.plugins.view.dashboard.Dashboard","name":"snap (build)"}
. Yet callingview.list_jobs('snap (build)')
will result in an exception being raisedRuntimeError: The view snap (build) doesn't exists on the server
.Reason being
#list_jobs
internally does the following#exists?
in turn callsand in
#list
the view_name is then interpolated into a regexat this point the "filter" (which was our view_name) will produce a bogus regex as we'll effectively have
/snap (build)/i
which isn't at all what the initial method call of#list_jobs
wanted.To fix this
exists?(x)
should probably beThe text was updated successfully, but these errors were encountered: