Evergreen Python Client

3.15.0 · active · verified Sat Apr 11

evergreen-py is a Python client library for interacting with the Evergreen API, specifically supporting its V2 version. It allows developers to build Python tools for Evergreen or use it on the command line to retrieve data about Evergreen objects. The library is actively maintained with automatic deployments to PyPI on merges to the master branch, following a semver versioning scheme. The current version is 3.15.0.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to authenticate with the Evergreen API and fetch a project by its ID. It's crucial to provide your Evergreen username and API key, ideally via environment variables, or through an `.evergreen.yml` file.

import os
from evergreen.api import EvgAuth, EvergreenApi

# It's recommended to set EVERGREEN_USERNAME and EVERGREEN_API_KEY as environment variables
username = os.environ.get('EVERGREEN_USERNAME', 'your_evergreen_username')
api_key = os.environ.get('EVERGREEN_API_KEY', 'your_evergreen_api_key')

# Ensure credentials are provided (replace with actual credentials or env vars)
if not username or not api_key:
    print("Please set EVERGREEN_USERNAME and EVERGREEN_API_KEY environment variables or provide them directly.")
else:
    auth = EvgAuth(username, api_key)
    api = EvergreenApi.get_api(auth)
    try:
        project = api.project_by_id('mongodb-mongo-master')
        print(f"Project Display Name: {project.display_name}")
    except Exception as e:
        print(f"Error fetching project: {e}. Please check your credentials and project ID.")

view raw JSON →