1. What is CI/CD in software development?
Answer: CI (Continuous Integration) is the practice of regularly integrating code into a shared repository, typically several times a day, followed by automated builds and tests. CD (Continuous Deployment/Delivery) is the practice of automatically deploying the integrated code to production or staging environments after passing CI.
2. Why is CI/CD important in modern development?
Answer: CI/CD ensures faster delivery, reduces manual errors, improves code quality, and provides quick feedback. It enables DevOps practices and facilitates rapid iteration.
3. What tools are commonly used for CI/CD in .NET?
Answer: Azure DevOps, GitHub Actions, Jenkins, TeamCity, GitLab CI, Octopus Deploy, and CircleCI.
4. What is a build pipeline?
Answer: A build pipeline is an automated process that compiles the code, runs tests, and prepares the application for deployment. It typically includes steps like fetching code, restoring dependencies, building the solution, running unit tests, and publishing artifacts.
5. What is the difference between Continuous Delivery and Continuous Deployment?
Answer: Continuous Delivery ensures code is always in a deployable state but requires manual approval to release. Continuous Deployment automatically deploys every change that passes all stages of the pipeline.
6. What is YAML and how is it used in CI/CD?
Answer: YAML is a human-readable configuration language used to define CI/CD pipelines, especially in tools like Azure DevOps and GitHub Actions.
7. How do you handle secrets and sensitive data in pipelines?
Answer: Use secret management tools like Azure Key Vault, GitHub Secrets, or environment variables stored in encrypted formats. Never hard-code secrets in the pipeline script.
8. What are artifacts in CI/CD?
Answer: Artifacts are the output files generated after the build process, such as DLLs, EXEs, NuGet packages, or deployment packages, which are passed to the release pipeline.
9. What is a release pipeline?
Answer: A release pipeline automates the deployment of build artifacts to different environments such as dev, staging, or production.
10. How does Azure DevOps support CI/CD?
Answer: Azure DevOps provides end-to-end support through Azure Repos (source control), Pipelines (CI/CD), Boards (agile planning), Artifacts (package management), and Test Plans.
11. Explain a typical CI/CD workflow for a .NET Core app.
Answer:
Developer pushes code to Git repository
Trigger CI pipeline
Restore dependencies using
dotnet restore
Build project using
dotnet build
Run tests with
dotnet test
Publish artifact with
dotnet publish
Release pipeline deploys artifact to test/staging/production
12. How do you ensure quality in CI/CD pipelines?
Answer: Use automated testing, code quality tools (SonarQube, Coverlet), linting, static code analysis, and pre-deployment validations.
13. What is Infrastructure as Code (IaC) in the context of CI/CD?
Answer: IaC automates infrastructure provisioning using code. Tools like Terraform, ARM templates, and Bicep are used to manage environments as part of CI/CD.
14. What are self-hosted agents in Azure DevOps?
Answer: These are custom machines configured to run builds or deployments instead of using Microsoft-hosted agents, offering more control and customization.
15. What is a rollback strategy in CI/CD?
Answer: Rollback strategies restore the previous stable version if a deployment fails. Strategies include blue-green deployments, canary releases, and manual rollbacks.
16. How do you handle database changes in CI/CD?
Answer: Use migration tools like Entity Framework Migrations or Flyway, and run scripts as part of the deployment pipeline, ideally with pre- and post-deployment gates.
17. What is a deployment slot in Azure App Service?
Answer: A deployment slot is a live app environment (e.g., staging, production) that allows you to test before swapping into production with zero downtime.
18. What are build triggers?
Answer: Build triggers automatically start a build on certain events, such as a code push, pull request, or scheduled time.
19. What is a pull request validation pipeline?
Answer: It runs the pipeline on the changes in a pull request to ensure the new code doesn't break existing functionality before merging into the main branch.
20. How do you manage multi-environment configurations in CI/CD?
Answer: Use variable groups, environment-specific JSON files, or configuration providers like Azure App Configuration.
21. What is Canary deployment?
Answer: It's a strategy where new code is gradually rolled out to a small subset of users before full deployment to monitor performance and catch issues.
22. What is Blue-Green deployment?
Answer: It involves two identical production environments. You deploy to the idle (green) one and switch traffic from the current (blue) one after testing.
23. What is the role of unit tests in CI/CD?
Answer: Unit tests verify individual components of the application and are the first line of defense against bugs, ensuring code quality before integration.
24. How do you use GitHub Actions for .NET CI/CD?
Answer: Define workflows in .github/workflows/ci.yml
, use dotnet
CLI commands, and add steps for build, test, and deployment.
25. How do you version artifacts in CI/CD?
Answer: Use semantic versioning or build numbers generated dynamically by the pipeline. Store versions in NuGet or Docker registries.
26. How do you monitor CI/CD pipelines?
Answer: Use tools like Azure Monitor, Application Insights, and logging frameworks like Serilog or ELK Stack to track build/deploy status and issues.
27. What are pipeline gates?
Answer: Gates are validations or approvals that must be completed before continuing to the next pipeline stage. Examples: approvals, security checks, test results.
28. What is the use of tags in CI/CD pipelines?
Answer: Tags can be used to mark specific commits, versions, or build runs for deployment or rollback reference.
29. How do you secure CI/CD pipelines?
Answer: Use role-based access control (RBAC), encrypted secrets, audit logs, secure service connections, and minimal permissions.
30. What is a typical folder structure for .NET projects in CI/CD?
Answer:
/solution
/src
/WebApp
/API
/tests
/WebApp.Tests
/API.Tests
/build
azure-pipelines.yml
This structure separates code and test logic and makes it easy to automate pipelines.
Comments
Post a Comment