Search and collect files across Azure Devops Organizations
Project description
Azure DevOps Harvester
A CLI tool and Python library to search across Azure Devops repositories, with built-in support for downloading matched files. It utilizes Azure Devops APIs for Search, and Retrieval.
Features
- 🔍 Search across all repositories in an organization
- 📁 Search file contents using Azure DevOps Code Search API
- 🎯 Filter by specific projects
- 📥 Download matched files using Git Items API with hash-based naming
- 📊 Beautiful formatted output with Rich
- ⚡ Parallel downloads with 5 concurrent workers
- 🔐 SHA256 hash verification for downloaded files
- 🐍 Python library for programmatic access
Installation
From PyPI (Recommended)
pip install azdo-harvest
From Source
git clone https://github.com/rothoma2/azdo-harvest.git
cd azdo-harvest
poetry install
Configuration
The tool requires a Personal Access Token (PAT) from Azure DevOps with at least Code (Read) permissions.
Creating a PAT
- Go to Azure DevOps:
https://dev.azure.com/{your-org} - Click on User Settings (top right) → Personal Access Tokens
- Create a new token with Code (Read) scope
- Copy the token (you won't see it again!)
Setting up authentication
You can provide the PAT in two ways:
-
Environment variable (recommended):
export AZDO_PAT="your-personal-access-token"
-
Command-line option:
azdo-harvest search "term" --organization myorg --project myproject
Usage
Basic Search (Summary Mode)
By default, the CLI shows only a summary of results:
azdo-harvest search "file:Dockerfile" --organization myorg --project myproject
Output:
Searching for: file:Dockerfile
Organization: myorg
Project: myproject
✓ Found 2 repositories and 2 files
Download Files
Use --download or -d to automatically download all found files:
azdo-harvest search "file:Dockerfile" --organization myorg --project myproject --download
Files are downloaded with naming format: {repository}__{filename}__{hash}
- Example:
docker-test__Dockerfile__a4b3c5d7.txt - Hash is the first 8 characters of SHA256 hash of file content
- Ensures unique filenames even for files with same name
Specify custom output directory:
azdo-harvest search "file:*.py" -o myorg -p myproject --download --output-dir ./my-files
Verbose Mode
Use --verbose or -v to see detailed tables:
azdo-harvest search "TODO" --organization myorg --project myproject --verbose
Search Options
Search in a specific project:
azdo-harvest search "configuration" --organization myorg --project MyProject
Search only in file contents
azdo-harvest search "function" --organization myorg --project myproject --file-only
Search only repository names
azdo-harvest search "api" --organization myorg --project myproject --repo-only
Limit results
azdo-harvest search "test" --organization myorg --project myproject --limit 50
Complete example with all options
export AZDO_PAT="your-personal-access-token"
azdo-harvest search "file:Dockerfile" \
--organization myorg \
--project MyProject \
--download \
--output-dir ./dockerfiles \
--verbose
Features:
- ⚡ Parallel downloads with 5 concurrent workers
- 📊 Progress bar showing download status
- ✓ Success/failure summary
- 🎯 Unique file naming:
repo__filename__hash.ext - 🔐 SHA256 hash for file verification
Command Reference
azdo-harvest search SEARCH_TERM [OPTIONS]
Arguments:
SEARCH_TERM The term to search for in repositories and files
Options:
-o, --organization TEXT Azure DevOps organization name [required]
-p, --project TEXT Project name [required]
--pat TEXT Personal Access Token (or set AZDO_PAT env var) [required]
--file-only Search only in file contents
--repo-only Search only repository names
-l, --limit INTEGER Maximum number of results [default: 100]
-d, --download Download all found files
--output-dir PATH Directory to save downloaded files [default: ./downloads]
-v, --verbose Show detailed results tables
--help Show this message and exit
Python Library Usage
The package can also be used as a Python library:
import os
from azdo_harvest import AzureDevOpsSearcher
# Initialize
organization = "your-org"
project = "your-project"
pat = os.environ['AZDO_PAT']
searcher = AzureDevOpsSearcher(organization, project, pat)
# Search for files
results = searcher.search(
search_term="file:Dockerfile",
project=project,
search_files=True,
search_repos=False,
max_results=10
)
# Access file results (FileResult objects)
for file in results['files']:
print(f"Found: {file.repository}:{file.filepath}")
print(f"Branch: {file.branch}")
print(f"Download URL: {file.get_download_url()}")
# Download files
output_path = searcher.downloader.download_file(
results['files'][0],
output_dir="./downloads",
preserve_structure=True
)
# Or get file content without downloading
content = searcher.downloader.get_file_content(results['files'][0])
Requirements
- Python >= 3.12
- Azure DevOps organization with Code Search enabled
- Personal Access Token with Code (Read) permissions
License
MIT - See LICENSE file for details
Author
rothoma2 - GitHub
Acknowledgments
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file azdo_harvest-0.2.0.tar.gz.
File metadata
- Download URL: azdo_harvest-0.2.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
391d6cdd778e5c44512a63cfe9c5ce273c883574509c07b1f5329ffbed3e91eb
|
|
| MD5 |
9efd64cec18e0ca8996926c58324788f
|
|
| BLAKE2b-256 |
45a923f3985f202d4d697805315f68e51f95a41471503d8a66dca0aad7ab7081
|
Provenance
The following attestation bundles were made for azdo_harvest-0.2.0.tar.gz:
Publisher:
publish.yml on rothoma2/azdo-harvest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
azdo_harvest-0.2.0.tar.gz -
Subject digest:
391d6cdd778e5c44512a63cfe9c5ce273c883574509c07b1f5329ffbed3e91eb - Sigstore transparency entry: 699934396
- Sigstore integration time:
-
Permalink:
rothoma2/azdo-harvest@35961443aae8f3b0d4f81204dee93720b8b091dd -
Branch / Tag:
refs/tags/v0.2 - Owner: https://github.com/rothoma2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@35961443aae8f3b0d4f81204dee93720b8b091dd -
Trigger Event:
release
-
Statement type:
File details
Details for the file azdo_harvest-0.2.0-py3-none-any.whl.
File metadata
- Download URL: azdo_harvest-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c374236acef3123fbe90e6b029594458e389a18add019c6b36f1926892b724e
|
|
| MD5 |
d1b9de8a81a71588407ffea43d400b8d
|
|
| BLAKE2b-256 |
a29bc4c715da4253b9e0be3d54d8573872f47dbf12a3d1e59116dd368472635d
|
Provenance
The following attestation bundles were made for azdo_harvest-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on rothoma2/azdo-harvest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
azdo_harvest-0.2.0-py3-none-any.whl -
Subject digest:
4c374236acef3123fbe90e6b029594458e389a18add019c6b36f1926892b724e - Sigstore transparency entry: 699934399
- Sigstore integration time:
-
Permalink:
rothoma2/azdo-harvest@35961443aae8f3b0d4f81204dee93720b8b091dd -
Branch / Tag:
refs/tags/v0.2 - Owner: https://github.com/rothoma2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@35961443aae8f3b0d4f81204dee93720b8b091dd -
Trigger Event:
release
-
Statement type: