This script allows you to disable the build server analysis setting for multiple repositories in your Codacy organization.
- Retrieves all repositories from your Codacy organization
- Allows you to select specific repositories or all repositories to update
- Attempts to disable build server analysis for selected repositories
- Provides detailed logging and a summary report
- Python 3.6 or higher
- Required Python packages:
- requests
- python-dotenv
- Clone this repository or download the files
- Install the required packages:
pip install -r requirements.txt- Copy the
.env.templatefile to.env:
cp .env.template .env- Edit the
.envfile and fill in your Codacy API token, Git provider, and organization name
disable_build_analysis.py: Main script.env.template: Template for environment variables.env: Your actual credentials (gitignored)requirements.txt: Required Python packages.gitignore: Prevents sensitive and generated files from being committedlogs/: Directory for log files (gitignored)
Run the script:
python disable_build_analysis.pyThe script will:
- Fetch all repositories from your Codacy organization
- Display a list of all repositories
- Prompt you to select which repositories to update
- Attempt to disable build server analysis for the selected repositories
- Display a summary report of the results
When prompted to select repositories, you can:
- Enter specific repository numbers separated by commas (e.g.,
1,3,5) - Enter a range of repository numbers (e.g.,
1-5) - Enter
allto select all repositories
The script creates detailed logs in the logs directory. Each run creates a new log file with a timestamp in the filename.
- List repositories:
GET /organizations/{provider}/{remoteOrganizationName}/repositories - Get build server analysis setting:
GET /organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/analysis - Update build server analysis setting:
PATCH /organizations/{provider}/{remoteOrganizationName}/repositories/{repositoryName}/settings/analysis