Interview Prep/Python for DevOps/Automation scripting & CLI design

Product wants a Slack notification whenever a deploy finishes. You have 30 minutes. What do you build?

BeginnerScenarioAutomation scripting & CLI design
Answer

Situation read → Small, well-scoped integration; the risk is leaking the webhook URL or blocking the deploy on Slack.

What I'd do →

  1. Create a Slack incoming webhook; store the URL as a CI secret.
  2. Add a tiny script or step:
import os, requests
resp = requests.post(os.environ["SLACK_WEBHOOK_URL"],
                     json={"text": f":rocket: {os.environ['SERVICE']} {os.environ['VERSION']} deployed to prod"},
                     timeout=5)
resp.raise_for_status()
  1. Run it with if: always() and report success or failure; make the notify step non-blocking (continue-on-error: true).

Why → A notification must never fail a successful deploy.

Interview tip → Mention keeping the webhook URL secret; it is a credential.

All Python for DevOps questions Roadmap: Python for automation

More on Automation scripting & CLI design