Bitbucket to elasticsearch connector written in Python. It supports indexing files and repos, updates and deletions. Read more on our blog: http://blog.comperiosearch.com/blog/2014/09/18/bitbucket-elasticsearch-connector/
- python 2.7
- requests (pip install requests)
- requests_oauthlib
- elasticsearch (pip install elasticsearch)
Create an OAuth key and secret
OAuth needs a key and secret together these are known as an OAuth consumer. You can create a consumer on any existing individual or team account. To create a consumer, do the following:
- Log into your Bitbucket account.
- Click accountname > Manage account from the menu.
- Click OAuth under ACCESS MANAGEMENT.
- Click the Add consumer button (Give it a name, description, etc.).
Add the Key and Secret to bitbucket.conf
- bitbucket.conf
- elasticsearch.conf
In bitbucket.conf you can set the keys for the API (as explained above) and you also need to change the [USERNAME] in "repos_endpoint" to be your username or the team's username.
In elasticsearch.conf you can set the elasticsearch host address, index name and maximum size for files to be indexed (this max size will only affect whether or not to index the content of the file, all other fields will be indexed).
python main.py index
index
update
pindex
To fully index your bitbucket content use the index mode, you can also use the experimental pindex mode which runs different python processes in parallel each indexing 10 repos.
To update your elasticsearch index (for newly added, updated or deleted files/repos) use the update mode, this will use a history file named .bitbucketHistory to keep track of when the script was last ran.