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

We have a private Atlassian Bitbucket Server (formerly known as Stash), which hosts our git repositories.

How can I search through

  • all source files
  • in all branches
  • in all repositories

I really want to avoid the process of checking all repositories locally by doing git pull and then recursively grep .

Some plugins were available in Atlassian Stash for "corporate search", but they did not work for us.

If you succeed, please share the setup instructions :) :)

+7
source share
3 answers

We also needed to search for all of our Stash projects. Considering the various options, the best option was to install a dedicated OpenGrok .
The crontab server runs a script every 10 minutes to do the following:

  • Get a list of the entire project using the Stash API
  • For each project, get all repositories (again using the API)
  • For each repository, clone or pull if exists
    • If you need each branch, find all branches and a clone for each branch
  • Once all sources are ready, start OpenGrok indexing

This is very good for us, and it was easy to implement.
I think that ultimately this should be done with a built-in add-in, but it wasn’t at that time.

Hope this helps.

+4
source

Disclosure: I'm Bitbucket Product Manager (Stash)

Like others, this is not what is currently available in the product. The good news is that we are working on finding code at the moment. The bad news for your question is that for performance reasons (and because this is a relatively rarely used case from our research), we plan to index the top of the default branch (usually a master).

If you could describe what you are trying to achieve in more detail, I will gladly consider the alternatives.

One option: a script to execute a series of "git grep" commands in the repositories on the server (provided that you have access). You do this at your own peril and risk, although any direct operations performed against repositories on the server are not supported.

+2
source

According to the Atlassian ticket , to track this, code search is built into Bitbucket Server 4.6 (aka Stash). See release notes .

+2
source

Source: https://habr.com/ru/post/1234675/


All Articles