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

We have a private Atlassian Stash server hosting our git repos.

How can I search across

  • Have JIRA send mails to watchers on commit from Stash on a ticket
  • How do I setup Carthage to use my own Frameworks that are in private repository like Stash (Bitbucket)?
  • How can I connect to my own Git server in SourceTree?
  • Delete multiple repositories at once in Atlassian Stash
  • git: How can I find out whether there is a pull request for a branch?
  • Migrate single repository from one Atlassian stash server to another server and maintain all data
    • 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 🙂 🙂

  • Line endings with cygwin and Github for Windows
  • Git server side hook not firing - how to check
  • Git/GitHub connection issue on VM/VirtualBox
  • git: Conflict upon merging back a cherry-picked commit
  • How to get a branch into a forked repo from the original repo in github
  • Anyway to use an external diff editor in Eclipse with EGit?
  • 3 Solutions collect form web for “How to search (grep) across all files, in all branches, in all repos in Stash?”

    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.

    Disclosure: I’m a Bitbucket (Stash) Product Manager

    As others have suggested, this isn’t something that’s available in-product currently. The good news is that we’re working on code search at the moment. The bad news for your question is that for performance reasons (and because it’s a relatively uncommon use case from our research) we are only planning to index the tip of the default branch (usually master).

    If you could describe what you’re trying to achieve in more detail I’d be happy to look into alternatives.

    One option would be to script up a series of “git grep” commands across the repos on the server (assuming you have access). You do this at your own risk though, any direct operations run against repos on the server aren’t supported.

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

    Git Baby is a git and github fan, let's start git clone.