Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searching for build number on builds fail #8

Open
hanabishi opened this issue Mar 16, 2016 · 1 comment
Open

Searching for build number on builds fail #8

hanabishi opened this issue Mar 16, 2016 · 1 comment

Comments

@hanabishi
Copy link
Contributor

The Jenkins link from the default Jenkins search plugin when standing on a build and searching for a build number will result in a broken link
When standing in job and searching for a build on that job.
https:///1955

@tobias-
Copy link
Contributor

tobias- commented Mar 17, 2016

(just random comments & mental notes (pun intended))

Can't really locate the problem. Without Lucene-search, an exact match will mean an immediate redirect, thus results can be returned as "?query=xxxxx" and it will do another search in the database and redirect to "xxxxx" when clicked. That has been changed with lucenesearch into returning a list with links directly to said place (without doing another search).

By adding the following kludge, things work as expected

public class SearchItemWrapper extends FreeTextSearchItem {
....
    @Override
    public String getSearchUrl() {
        try {
            java.lang.reflect.Field f = item.getClass().getDeclaredField("val$searchable");
            f.setAccessible(true);
            SearchableModelObject o = (SearchableModelObject) f.get(item);
            if (o instanceof Run) {
                Run<?, ?> build = (Run<?, ?>) o;
                return build.getParent().getParent().getUrl() + build.getParent().getSearchUrl() + build.getSearchUrl();
            } else if (o instanceof ItemGroup) {
                ItemGroup<?> build = (ItemGroup<?>) o;
                return build.getUrl();
            } else if (o instanceof Job) {
                Job build = (Job) o;
                return build.getParent().getUrl() + build.getSearchUrl();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

except that there are ~5-10 implementers of SearchModelObject in core, and an unknown amount outside of core.

Reimplementing the standard way didn't go as planned in the first attempt, and imho has no real advantage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants