Yes, developers and DevOps teams routinely create virtual machines as part of CI/CD pipelines, but usually not the way the question implies. In a modern pipeline, VMs are typically provisioned automatically by infrastructure-as-code tooling, not set up by hand by an individual developer each time a build runs. The phrase "set up VMs as part of CD" covers three quite different practices: using VMs as disposable build or test runners, provisioning VMs as part of deploying an application, and maintaining long-lived "pet" VMs that teams patch and reconfigure over time. The first two are common and considered good practice; the third is increasingly treated as legacy.

A useful rule of thumb: CI usually needs VMs as tools (build agents, test hosts, browsers, operating-system matrices), while CD may need VMs as targets (the servers or environments the application lands on). Mixing those two roles up is the source of most confusion around this question.

What "setting up a VM" actually means in a pipeline

Before deciding whether developers do this, it helps to separate the layers:

Infrastructure creation. Allocating compute, disk, and networking — for example, asking a cloud provider or hypervisor for a new virtual machine. Machine configuration. Installing packages, agents, runtimes, certificates, and users so the VM can do its job. Pipeline integration. Registering the VM as a runner, targeting it for deployment, or tearing it down afterward. Lifecycle management. Deciding how long it lives, how it is updated, and how it is destroyed.

Most real pipelines automate all four. The question is which layer a team chooses to own and which it delegates to a platform.

CI: VMs as disposable build and test runners

In continuous integration, the dominant pattern is ephemeral infrastructure: a fresh VM (or container) is created for a job, used, and destroyed. Self-hosted CI systems such as Jenkins have supported this for years through cloud plugins that spin up agents on demand and terminate them when idle. GitLab Runner's autoscaling executors do the same with cloud instances. This is genuine VM setup inside CI, but it is driven by configuration and API calls rather than a person clicking through a hypervisor console.

Teams choose VMs over containers in CI when they need something a container cannot easily provide:

Need Why a VM helps
Testing kernel modules or device drivers Containers share the host kernel
Running full Windows or macOS desktop environments Container support is limited or licensed differently
Testing against a specific OS version or patch level A VM gives an isolated, complete OS image
Hosting a CI agent with persistent caches or licenses Some software expects a long-lived machine identity
Strong isolation between untrusted builds A hypervisor boundary is stronger than a shared kernel

VMs are also the default when a pipeline must test an installer or an appliance image, because the artifact being validated is a machine.

CD: VMs as deployment targets

Continuous delivery and deployment often provision VMs as the place the application runs. The commonplace example is Terraform (or OpenTofu, CloudFormation, Bicep, or Pulumi) creating a set of instances behind a load balancer, followed by a configuration-management step — Ansible, cloud-init, or a baked machine image — that installs the application. Kubernetes clusters themselves are frequently built on VMs, so "the pipeline deployed to VMs" can be true even when the developer thinks in terms of pods.

There are two main philosophies here, and the distinction matters:

Baking builds a complete machine image (an AMI, a VM template, a golden image) in the pipeline, tests it, and deploys by launching instances from it. Configuration happens at build time, so boot is fast and drift is limited. Frying launches a generic base image and configures it at deploy time through a provisioner or agent. This is simpler to start with but slower and more fragile, because every deployment depends on external package sources and network access.

Modern practice leans toward baking, or toward immutable images replaced rather than patched in place. That shift is the main reason "developers set up VMs" sounds old-fashioned: the VM is now an interchangeable artifact, not a hand-tended server.

Where the practice is common — and where it is fading

VM provisioning in CD is standard in several situations:

Regulated or on-premises environments where a private cloud (VMware, OpenStack, Proxmox, Hyper-V) is the sanctioned platform. Windows-heavy shops, where VM-based build agents remain common. Legacy applications that assume a full operating system and cannot be containerized economically. Security-sensitive pipelines that need hardware-level isolation between tenants. Learning and small teams, where a single script that creates a VM, installs Docker, and deploys is a pragmatic first step.

It is less common, or actively discouraged, when a team has standardized on managed container platforms or serverless. In those settings, the VM still exists underneath, but the pipeline never addresses it directly — the platform does. This is why two engineers can give opposite answers to the same question without either being wrong: one is describing their infrastructure, the other is describing their abstraction layer.

The "pet versus cattle" distinction

The most important idea for judging whether VM setup in a pipeline is healthy is the pet-versus-cattle metaphor popularized in infrastructure operations. A pet server is named, hand-configured, and nursed back to health when it fails. Cattle are numbered, replaceable, and destroyed and recreated when something goes wrong.

Pipelines that create VMs from code and destroy them on teardown are treating them as cattle, even if the VMs are long-lived. Pipelines that SSH into an existing machine and run a sequence of ad hoc commands are treating it as a pet, and that practice tends to accumulate the usual problems: undocumented state, configuration drift, snowflake servers that nobody dares rebuild, and deployments that fail because someone changed something by hand months ago.

If you are evaluating your own setup, the diagnostic question is simple: can the pipeline rebuild this VM from nothing, unattended, and get the same result? If yes, you are doing infrastructure as code in the healthy sense. If no, the VM setup is manual in disguise.

How it typically looks in practice

A representative pipeline for a VM-based deployment has four stages:

1: Validate and build. Lint the Terraform or CloudFormation, build the application artifact, and bake a machine image if the team uses the image-based approach. 2: Provision. Apply the infrastructure plan to create or update instances. Idempotent tools matter here — rerunning the step should converge, not duplicate. 3: Configure and deploy. Either the new instances already contain the app (baked image) or a provisioner installs it. Health checks gate the next step. 4: Verify and clean up. Run smoke tests, then destroy temporary environments. Ephemeral preview environments — a full VM stack per pull request — are a well-established pattern in larger organizations, and they only work because creation and destruction are automated.

Environment parity is the payoff. If staging and production are both created by the same code path, the classic "it worked on staging" failure loses one of its main causes.

Costs, risks, and trade-offs

VM-based pipelines are not free of problems, and a candid answer has to name them.

Boot time. A VM takes tens of seconds to minutes to start, versus sub-second container startup. Ephemeral VMs slow feedback loops unless images are pre-baked and pools are warm. Cost. Idle VMs bill by the hour. Autoscaling and aggressive teardown are essential. Image maintenance. Golden images go stale. Base images need patching, and the pipeline must be able to rebuild them on a schedule. Credentials and blast radius. A pipeline with permission to create and destroy VMs has broad access. Least-privilege roles, short-lived credentials, and separation between build and deploy identities are not optional. Drift. Any manual change to a provisioned VM undermines the next automated run. Teams either forbid manual access or reconcile drift explicitly. State management. Terraform-style tools keep state files, and mishandling that state — concurrent applies, lost state, unversioned backends — is a common source of outages.

None of these argue against VMs; they argue for treating VM setup as software with tests, reviews, and version control.

Common misconceptions

A few beliefs cause confusion around this question:

"CI/CD means containers now." Containers are popular, but plenty of pipelines still create VMs, and many container platforms run on VMs provisioned by the same pipeline. "Developers shouldn't touch infrastructure." In many teams, platform engineers own the modules and developers consume them; in others, developers own their service's infrastructure code. Both are legitimate. What is not legitimate is unmanaged manual setup. "VMs in CD are legacy." Long-lived VMs are declining, but ephemeral VMs as build and test infrastructure are entirely current, especially for OS-level and hardware-level testing. "The pipeline sets up the VM" means a person does it. It means code does it. That is the whole point.

A short decision guide

If you are deciding whether to add VM provisioning to your pipeline, ask:

Does the workload need a full OS, a specific kernel, or a non-Linux platform? If so, VMs are a reasonable fit. Can the artifact be containerized without losing fidelity? If so, containers will usually be faster and cheaper. Can the VM be created and destroyed entirely from code, with no manual steps? If not, fix that before scaling the practice. Is the base image rebuilt on a schedule and tested? If not, patching will become an emergency. Are credentials scoped to only what the pipeline needs? If not, the VM step is a security liability.

Bottom line

Developers do set up VMs as part of CI/CD, and doing so is normal in many organizations. The mature version of the practice is declarative and automated: infrastructure code creates the machines, configuration management or pre-baked images define their contents, and teardown is part of the pipeline rather than an afterthought. The immature version — logging into a box and typing commands as a deployment step — is what the industry has spent the last decade moving away from. The distinction between VMs as disposable tools and VMs as hand-maintained pets is the one that actually determines whether the setup helps or hurts.