VSTS集成CI/CD的Git Flow流程咨询及工具集成疑问
Hey there, let's unpack your Git Flow + VSTS CI/CD questions clearly—this stuff can feel overwhelming at first, but once you align the branches with your pipeline stages, it all falls into place. Here's a breakdown tailored to your needs:
Core Questions Answered
1. Does integration release start from the develop branch?
Absolutely. The develop branch is Git Flow's integration backbone—it's where all completed feature/* branches get merged. For your VSTS CI/CD pipeline, you should configure an automatic trigger: every time code is pushed or merged into develop, kick off an integration build, run unit/integration tests, and deploy to your staging/integration test environment. This ensures new changes don't break the existing integrated codebase.
2. Which branch should UAT releases come from? Is it master?
Nope, never use master for UAT. In standard Git Flow, UAT releases should originate from a release/* branch. Here's how it works:
- When
develophas all the features ready for user testing, create arelease/x.y.zbranch (e.g.,release/1.2.0) fromdevelop. - This branch is dedicated to UAT: any bugs found during testing get fixed directly in the
releasebranch, not back indevelop. - Your VSTS pipeline can auto-deploy this
releasebranch to your UAT environment as soon as it's created.
3. Does production release start from the master branch?
Yes, 100%. The master branch in Git Flow is your single source of truth for production-ready code. Every code change in master should have gone through integration testing, UAT, and formal approval. In VSTS, set up a trigger that fires when code is merged into master (or when a version tag like v1.2.0 is pushed) to kick off your production deployment pipeline. This guarantees that only validated, stable code reaches production.
4. Where should static analysis tools like SonarQube be integrated?
Static analysis should run at multiple checkpoints to catch issues early, but focus on these key branches:
feature/*branches: Enforce Sonar checks as part of your PR process in VSTS. Require that any PR todeveloppasses Sonar's quality gates (e.g., no critical vulnerabilities, minimum code coverage) before it can be merged. This stops bad code from entering the integration pipeline.developandrelease/*branches: Auto-run Sonar analysis every time code is pushed. Fordevelop, this ensures the integrated codebase maintains quality; forrelease/*, it confirms no new issues were introduced during UAT bug fixes.- Optional:
masterbranch: Run a final Sonar scan as a safety net before production deployment, though if your earlier checks are solid, this is mostly a redundant (but reassuring) step.
Recommended Git Flow + VSTS CI/CD Workflow
Here's a streamlined, production-ready workflow tailored to your scenario:
- Feature Development:
- Developers create
feature/[feature-name]branches fromdevelop. - On PR submission to
develop, VSTS triggers: code review checks, unit tests, Sonar analysis, and a preview build. - Only after all quality gates pass is the PR merged into
develop.
- Developers create
- Integration Validation:
- Merge into
developtriggers VSTS to build, run integration tests, and deploy to your integration test environment. - Monitor this environment to ensure the integrated codebase is stable.
- Merge into
- UAT Phase:
- When ready for UAT, create a
release/x.y.zbranch fromdevelop. - VSTS auto-deploys this branch to UAT; any bugs are fixed directly in the
releasebranch, with deployments re-triggered on each fix.
- When ready for UAT, create a
- Production Release:
- Once UAT passes, merge
release/x.y.zintomasterand tag the commit withv.x.y.z. - VSTS detects the merge/tag and triggers production deployment.
- Merge the
releasebranch back intodevelopto sync bug fixes with the integration backbone.
- Once UAT passes, merge
- Hotfixes for Production:
- For urgent production bugs, create a
hotfix/x.y.z-hotfix1branch frommaster. - Fix the bug, test it in a dedicated hotfix test environment (or UAT), then merge back into
master(with a new tag) anddevelop. - VSTS triggers production deployment for the hotfix tag.
- For urgent production bugs, create a
内容的提问来源于stack exchange,提问作者Vipin

