The Simplest Way to Make Luigi and Teamcity Work Like They Should
Teams use luigi and teamcity together to test, build, and run Python data pipelines. TeamCity checks your code and builds artifacts, while Luigi orders tasks and tracks data outputs. This setup splits software delivery from data batch logic. Developers push code to a git repo, and TeamCity runs unit tests right away. When tests pass, TeamCity ships the updated task package to the worker nodes. Luigi then runs the batch jobs in the right order and checks for finished files. How permissions and
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Teams use luigi and teamcity together to test, build, and run Python data pipelines. TeamCity checks your code and builds artifacts, while Luigi orders tasks and tracks data outputs.
This setup splits software delivery from data batch logic. Developers push code to a git repo, and TeamCity runs unit tests right away. When tests pass, TeamCity ships the updated task package to the worker nodes. Luigi then runs the batch jobs in the right order and checks for finished files.
How permissions and data flow between luigi and teamcity
A clean flow between these two tools starts with clear roles and keys. TeamCity needs a key to pull source code and push build packages to storage. Build agents should only have the right to write packages to one specific bucket. They do not need the right to read or change live production databases.
Once the build step ends, TeamCity can trigger a Luigi run or update the worker host. At this point, the Luigi worker takes over the job. The Luigi worker uses its own role to log in to data stores and run queries. The central Luigi planner tracks which tasks are waiting, running, or done. The planner only gets status updates and does not touch raw data.
Data flows in one direction during the build phase. Code moves from git to TeamCity, and then to the Luigi worker host. During the run phase, Luigi pulls raw data, runs Python logic, and writes out clean files. If a task fails, Luigi stops the downstream tasks and sends the status back.
Common failure modes and how to scope roles
The biggest mistake teams make is sharing one static key across both tools. When a build agent and a data worker use the same account, risk goes up. Anyone who can edit a build script can then pull live customer records. Shared accounts also make it hard to see which person or job ran a bad query.
Another common issue is running heavy Luigi data tasks right inside a TeamCity build agent. Build agents are made to compile code and run fast tests. When you run long batch jobs on them, you block other devs from shipping code. You also mix build secrets with production data secrets on the same machine.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Unlogged database queries also cause huge headaches for data teams. When a Python task runs a query with a shared user name, logs lack detail. You can see the query, but you do not know which build or user started it. If a query contains sensitive fields like emails or card numbers, raw results may leak into build logs.
To fix these failure modes, split your network paths and roles right away. Give TeamCity agents a narrow role that only ships code to your worker hosts. Give each Luigi worker a scoped role that only reads and writes the tables it needs. Turn on query logging and use data masking to rewrite phone numbers and national IDs in results.
Keeping builds and batch runs stable at scale
As your team grows, you will add more pipelines and more build agents. Keep your Luigi task code small and test it with fake data inside TeamCity. Never let a test job reach out to a live production database during a build. Use mock files so tests run fast and stay safe.
You should also track the versions of your Python packages on every build. TeamCity can pack your code and its exact package list into a single archive. When the Luigi worker runs the job, it uses that exact archive every time. This stops broken runs caused by missing libraries on the worker host.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Should TeamCity run Luigi tasks directly on build agents?
No, build agents should only test code and ship packages to your worker hosts. Let dedicated Luigi workers run the heavy data tasks so builds never stall.
How do we handle database keys between both tools?
Give TeamCity keys for code deployment only, and give Luigi workers separate keys for data stores. Never share one broad service account between your build server and your data workers.
How does Luigi know when a TeamCity build finishes?
TeamCity can deploy the new code package and then trigger the Luigi scheduler API. You can also let a timer start Luigi after the build step puts files in place.
Related guides
In this post