Operations 6 min read

Creating Dynamic Test Environments per Pull Request with TFS Release Pipelines

The article explains how to use TFS release pipelines, environment variables, and feature‑branch pull requests to automatically provision isolated test environments for each PR, enabling end‑to‑end continuous delivery linked to user stories.

DevOps
DevOps
DevOps
Creating Dynamic Test Environments per Pull Request with TFS Release Pipelines

In the final part of the "Git Enterprise Developer Tutorial" the author emphasizes using Pull Requests (PR) together with CI/CD to improve code‑quality focus and enable continuous delivery scenarios.

The goal is to automatically create a dedicated test environment for every PR, so each feature branch associated with a user story gets its own isolated environment, forming a complete delivery chain: user story → feature branch → PR → environment.

When a developer creates a branch and opens a PR, an environment matching the changes is provisioned instantly, without interfering with other branches, allowing the team to clearly see which story is being tested where.

To achieve this, the team leverages the "Control Options" and "Environment Variables" features in TFS release pipelines, configuring multiple parallel test environments plus a production environment.

Three Azure resource groups are used as independent environments (TEST‑ENV‑01, TEST‑ENV‑02, TEST‑ENV‑03), each bound to the same variable name ResourceGroupName but with different values, enabling separate deployment and teardown.

Another set of variables maps specific Pull Request IDs to these environments, so PR 1, PR 2, and PR 3 each target a distinct test environment.

The pipeline task’s control option is configured with a custom condition using a variable expression to select the correct environment based on the PR ref:

and(succeeded(), startsWith(variables['Release.Artifacts.YoTeamAspDemoApp5322-CI.SourceBranch'], variables['PullRequestID']))

Two key variables are used: Release.Artifacts.YoTeamAspDemoApp5322-CI.SourceBranch , which TFS provides to identify the source branch (or PR ref), and PullRequestID , which holds the PR identifier set earlier in the pipeline.

By updating the environment variable with the PR ref, the pipeline automatically deploys the PR to the corresponding test environment; only the matched environment runs while others are skipped.

The current TFS version (2018 U2) does not support using the PR ref directly as a branch filter, a limitation reported to Microsoft for future releases.

ci/cddevopsEnvironment VariablesAzureFeature BranchTFSpull request
DevOps
Written by

DevOps

Share premium content and events on trends, applications, and practices in development efficiency, AI and related technologies. The IDCF International DevOps Coach Federation trains end‑to‑end development‑efficiency talent, linking high‑performance organizations and individuals to achieve excellence.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.