DEV Community

Danish Khan
Danish Khan

Posted on

๐Ÿš€ Python for SRE/DevOps: Building SDKs + Jenkins Automations

A practical, step-by-step roadmap to learn how to:

  • Build reusable Python SDKs
  • Package and publish them
  • Use them in Jenkins pipelines
  • Automate real-world SRE workflows (alerts, infra, APIs)

๐Ÿง  Big Picture Architecture

Python Script โ†’ Internal SDK โ†’ HTTP API โ†’ External System โ†’ Jenkins (cron/scheduled execution)

You are learning how to build internal automation platforms, not just scripts.


๐Ÿ“š Phase 1: Python Foundations (Automation-Focused)

What to Learn

  • Functions, modules, imports
  • Virtual environments (venv)
  • JSON & YAML handling
  • Exception handling
  • Basic classes & objects

Resources


๐ŸŒ Phase 2: APIs First (Before SDKs)

What to Learn

  • HTTP methods: GET, POST, DELETE
  • Headers & authentication
  • JSON request/response
  • Status codes
  • Timeouts & Retries

Resources


๐Ÿงช Practice

Write a script that:

  • Calls an API
  • Fetches data
  • Sends POST request
  • Deletes a resource

๐Ÿ“ฆ Phase 3: Python Packaging (VERY IMPORTANT)

What to Learn

  • setup.py vs pyproject.toml
  • pip install mechanics
  • wheel format
  • package versioning
  • private package repositories

Resources


๐Ÿงช Practice

  • Create a Python package
  • Build it (python -m build)
  • Install locally using pip
  • Import it in another project

๐Ÿ—๏ธ Phase 4: Building SDK-Style Code

What to Learn

  • Class-based design
  • Client abstraction
  • BaseClient pattern
  • Error handling
  • Code structure

Typical SDK Structure

my_sdk/
โ”œโ”€โ”€ client.py
โ”œโ”€โ”€ base_client.py
โ”œโ”€โ”€ models.py
โ”œโ”€โ”€ exceptions.py
โ”œโ”€โ”€ utils.py
โ””โ”€โ”€ init.py
Enter fullscreen mode Exit fullscreen mode

Resources


๐Ÿงช Practice

Build a client like:

client = MonitoringClient()
client.create_event()
client.get_events()
client.delete_event()
Enter fullscreen mode Exit fullscreen mode

โš™๏ธ Phase 5: Jenkins + Python Integration

What to Learn

  • Jenkins pipelines (Jenkinsfile)
  • Running Python scripts
  • Environment variables
  • Cron scheduling
  • Dependency installation (pip in pipeline)

Resources


๐Ÿงช Practice

Create pipeline:

  • Install package via pip
  • Run Python script
  • Capture output
  • Trigger via cron

๐Ÿงช Phase 6: Testing (CRITICAL for SRE)

What to Learn

  • pytest basics
  • mocking APIs
  • testing client methods
  • safe execution patterns

Resources


โšก Phase 7: Async Python (Advanced)

What to Learn

  • async / await
  • event loop
  • concurrent API calls
  • async HTTP clients

Resources


๐Ÿงฑ Real-World Pattern You Are Learning

This pattern is used everywhere in platform engineering:

  • Internal Python SDK
  • Published as package
  • Stored in private repo
  • Installed in pipelines
  • Used for automation tasks
  • Triggered via cron

๐Ÿ”ฅ Mini Project (Must Do)

Project: Monitoring Automation SDK

Structure

monitoring-sdk/
โ”œโ”€โ”€ monitoring_client/
โ”‚ โ”œโ”€โ”€ client.py
โ”‚ โ”œโ”€โ”€ base_client.py
โ”‚ โ”œโ”€โ”€ models.py
โ”‚ โ”œโ”€โ”€ exceptions.py
โ”‚ โ””โ”€โ”€ utils.py
โ”œโ”€โ”€ scripts/
โ”‚ โ”œโ”€โ”€ create_event.py
โ”‚ โ”œโ”€โ”€ cleanup_event.py
โ”œโ”€โ”€ tests/
โ”œโ”€โ”€ pyproject.toml
โ””โ”€โ”€ Jenkinsfile
Enter fullscreen mode Exit fullscreen mode

Features

  • Create event (POST)
  • List events (GET)
  • Delete event (DELETE)
  • Package SDK
  • Install via pip
  • Run via Jenkins

๐Ÿ“… 7-Day Fast-Track Plan

Day 1

  • Learn venv, pip
  • Run Python scripts

Day 2

  • Learn requests
  • Call an API

Day 3

  • Write API client class

Day 4

  • Convert to package

Day 5

  • Install package locally

Day 6

  • Write automation script

Day 7

  • Run via Jenkins pipeline

๐Ÿง  Final Insight

You are not learning Python.
You are learning to build:
๐Ÿ‘‰ Internal Developer Platforms
๐Ÿ‘‰ Automation of Toolings,API and Systems
๐Ÿ‘‰ Reusable Engineering Tools used internally and are created using Python

This is exactly what strong SREs/DevOps and Platform Engineers do.
This is how in future you can even contribute to Open Source Software


๐Ÿš€ Next Step : Coming Soon (WIP)

๐Ÿ‘‰ A complete working project template (SDK + Jenkins + API mock).
๐Ÿ‘‰ Tailored to this above workflow.

Just share it further on LinkedIn, Substack ๐Ÿ‘

Top comments (0)