Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search (grep) across all files, in all branches, in all repos in Stash?

We have a private Atlassian Bitbucket Server (previously known as Stash) hosting our git repos.

How can I search across

  • all source files
  • in all branches
  • in all repos

I really want to avoid the process of checking out all repos locally, doing git pull and then recursive grep.

Some plugins were available in Atlassian Stash for "enterprise search" but they didn't work for us.

If you have gotten this to work, kindly share the steps to set it up :) :)

like image 459
vikingsteve Avatar asked Oct 28 '15 08:10

vikingsteve


People also ask

How do I search all repositories in bitbucket?

To start searching in Bitbucket, select the search field in the upper-right corner of the top navigation bar, then enter either a single word or an entire phrase (in double quotes). The keyboard shortcut to start a search from anywhere in Bitbucket is " / ".

How do I search for files in bitbucket?

You can click on the magnifying glass on the left bar (top bar in the new layout) and directly type in the code. It'll allow for searching in the current repository or all your repositories. You can search both files as well as code: bitbucket.org/blog/…. An example would be bitbucket.org/…


1 Answers

We also needed to implement a search for all our Stash projects. Looking into various options, the best implementation was to install a dedicated OpenGrok server.
The server's crontab runs a script every 10 minutes for doing the following:

  1. Get list of all project using Stash API
  2. For each project, get all repositories (using the API again)
  3. For each repository, clone or pull if exists
    • If you need every branch, find all branches and clone for each branch
  4. Once all sources are ready, run the OpenGrok indexing

It works very well for us, and was simple to implement.
I think that eventually, this should be done with a built-in add-on, but at the time, there was none to be found.

I hope this helps.

like image 51
Eldad Assis Avatar answered Oct 15 '22 18:10

Eldad Assis