Table of Contents
وتوفر خطوط الأنابيب التي تستخدمها شركة Azure DevOps YAML نهجا صارما يتحكم في النسخ إزاء التكامل المستمر والتسليم المستمر (CI/CD) يتوافق تماما مع الممارسات الحديثة في مجال تنفيذ البرامجيات، وذلك بتدوين تعريف خط الأنابيب بأكمله في ملفات شركة YAML المخزنة إلى جانب رمز التطبيق، وتحقيق الأفرقة الشفافية، والقابلية للتكرار، والقابلية للتطابق مع ذلك، وهذا النهج يحول خط الأنابيب من صندوق أسود إلى مواطن من الدرجة الأولى من مجموعة بيانات نظام " شيفرة " .
وسواء كنت تقومين بتأهيل بناءات الخدمات الصغرى، ونشر الهياكل الأساسية كرمز، أو تنسقين سير العمل المعقدة المتعددة الأبعاد لإطلاقات البيئة، فإن خطوط الأنابيب التي تستخدمها شركة Azure DevOps YAML تعطيك التحكم والمرونة والقدرة على التصعيد اللازمة لشحن البرامجيات بصورة موثوقة، وهذه المادة توفر نظرة متعمقة لما هي خطوط الأنابيب التي تستخدمها الشبكة، وكيفية استحداثها، والأنماط المتقدمة، وأفضل الممارسات التي استخلصتها من الإنتاج.
ما هو "أزور ديفوبس يال بيبلين"؟
(أ) خطوط أنابيب (Azure DevOps YAML) هي ملفات للتشكيلات توضيحية تحدد الخطوات والمراحل والوظائف والعاليات المطلوبة لبناء واختبار ونشر الطلبات، خلافاً للمحرر التقليدي الذي يخزن تعاريف خطوط الأنابيب في قاعدة بيانات خدمة شركة Azure DevOps، توجد خطوط أنابيب للشبكة كملفات نصية في مستودعكم - تسمى عادة أو توضع في شكل [قائمة على أساس تجريبي]
ويمكن لملف خط الأنابيب أن يشير إلى ملفات أخرى من طراز YAML (الآفاق) للمنطق القابل لإعادة الاستخدام، وتشمل البيانات المشروطة والمتغيرات الدينامية، بل وتثير سلوكاً مختلفاً يقوم على أساس الفرع أو البطاقة أو مرشحات المسارات، مما يجعل عملية CI/CD عملية قابلة للوصف تماماً وقادرة على معالجة سيناريوهات العالم الحقيقي المعقدة دون تدخل يدوي.
العناصر الأساسية للخطابات التي يحملها YAML
A YAML pipeline is composed of several hierarchical elements that work together: triggers, variables, stages, jobs[FLT:
مراحل، وظائف، خطوات
(أ) تمثل الشُعب الرئيسية في خط الأنابيب، مثل البناء والاختبار والنشر، ويمكن أن تجري عمليات متعاقبة أو متوازية، وفي كل مرحلة، ، تحدد نماذج ] بيئة التنفيذ (مجموعة مواد أو حاوية صغيرة) وتتضمن سلسلة من [العمل: 5]
المصاريف
(أ) يحدد المُتجرون متى ينبغي أن يبدأ خط الأنابيب تلقائياً، وأكثرها شيوعاً هو إطلاق الصواريخ CI، الذي يشعل الإرتباطات في فروع محددة (مثلاً، ، ) ويمكنكم أيضاً استخدام مُحفزات إطلاق البطاقات من أجل التثبت من الطلب، والجدول الزمني للتشكيلات الليلية، والمسارات
trigger:
branches:
include:
- main
- releases/*
paths:
exclude:
- docs/*
- README.md
المتغيرات والمواصفات
Variables] store values that can be used throughout the pipeline — connection strings, version numbers, or environment names. They can be defined at the pipeline level, stage level, or job level, and can be overridden at queue tempue time. Parameters are a more powerful mechanism for introducingtime choices.
(أزور ديفوبس) يدعم أيضاً المتغيرات السرية التي تم تشفيرها ولم يتم كشفها في السجلات، من أجل الأسرار التي تُنتج،
نماذج إعادة الاستخدام
Templates] are one of the most powerful features of YAML pipelines. They allow you to factor out common logical into separate YAML files and include them in multiple pipelines. There are two types: ]job templates and steplate
مثلاً، يمكنك أن تخلق نموذجاً لـ "الملكة النخرية" يُستخدم في صيغة النودج كنموذج ويُديرها في التركيب والبناء والاختبار، وأي خط أنابيب يحتاج إلى بناء تطبيق للرقم يمكن أن يشمل ببساطة ذلك النموذج بالنسخة المناسبة، وهذا يزيل الازدواجية ويضمن الاتساق بين المشاريع.
# templates/build-node-app.yml
parameters:
- name: nodeVersion
type: string
default: '18.x'
steps:
- task: NodeTool@0
inputs:
versionSpec: ${{ parameters.nodeVersion }}
- script: npm install
displayName: 'Install dependencies'
- script: npm run build
displayName: 'Build application'
- script: npm test
displayName: 'Run tests'
الفوائد الرئيسية للشركة المتحكمة في الارتداد/الاتفاقية
وتُنتج عن اعتماد خطوط أنابيب " يام إل " عدة مزايا ملموسة على خطوط الأنابيب التقليدية القائمة على أساس اليورانيوم:
- Full version control:] Every change to the pipeline is tracked in the same repository as the application code. You can diff, comment, and roll back pipeline changes using standard Git workflows. This eliminates the "who changed the pipeline" vague and ensures that the pipeline definition is always in coincide with the code it builds.
- Reproducibility and auditability:] Because the pipeline is defined as code, you can rebuild any commit with exactly the same steps, variables, and dependencies as when it was first built. This is critical for debugging production issues and meeting compliance requirements.
- Automation beyond builds: ] YAML pipelines support conditional logical, cycles, and complex expressions using Azure DevOps' expression language. You can implement sophisticated workflows such as deploymenting to multiple regions in parallel, running smoke tests only on release branches, or triggering downstream pipelines.
- Portability:] YAML pipelines can be copied between projects, reused across teams, and even used to bootstrap CI/CD for new repositories. Templates further enhance this portability by allowing teams to share and maintain common pipeline logical centrally.
- Collaboration and code review:] Pipeline changes are subject to the same withdrawal request review process as source code. This encourages best practices like peer review of infrastructure changes, reduces misconfigurations, and fosters a culture of DevOps collaboration.
إنشاء خط بياني للتصوير
وضع خط أنابيب لليام والام من الصفر هو مستقيم، وفيما يلي الخطوات الموصى بها:
- Decide on a file structure.] You can place your main pipeline file at the root of the repository () or in a dedicated folder such as . The latter approach scales better when you have multiple pipelines.
- أكتب تعريف خط الأنابيب.] ابدأ بملف صافٍ من طراز YAML يتضمن محفزاً، ومجمعاً (صورة أو حاوية من طراز VM) ووظيفة واحدة على الأقل.
- ] Store the file in your repository.] Commit and push to the remote, making sure the file is in the branch you intend to use as the default branch for the pipeline.
- ] Create the pipeline in Azure DevOps.] Navigate to Pipelines > Create Pipeline, select "Azure Repos Git" (or your chosen source), choose the repository, and then select "existing Azure Pipelines YAML file you just created (e.T.
- Confirm and run.] Click "Run" to execute the pipeline for the first time. You can monitor the output in real time. Subsequent commits to the triggering branches will automatically start new runs.
وبالنسبة للمشاريع القائمة التي لديها بالفعل خط أنابيب كلاسيكي، يمكنك الانتقال إلى YAML بتصدير تعريف خط الأنابيب أو إعادة صياغته باستخدام محرر YAML.() وتوفر شركة مايكروسوفت دليلاً للهجرة لتخفيف الانتقال.
Sample Pipeline Walkthrough
لنفحص خط الأنابيب الأكثر واقعية لتطبيق (نودج) على الشبكة والذي يبني ويختبر وينشر قطعة أثرية وينشر في بيئة متنقلة، هذا المثال يدل على وجود عدة مراحل ومتغيرات ونشر مشروط.
trigger:
branches:
include:
- main
- develop
paths:
exclude:
- 'README.md'
variables:
nodeVersion: '18.x'
artifactName: 'webapp'
stages:
- stage: Build
displayName: 'Build and Test'
jobs:
- job: BuildJob
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: $(nodeVersion)
- script: npm install
displayName: 'Install dependencies'
- script: npm run lint
displayName: 'Lint code'
- script: npm run build
displayName: 'Build application'
- script: npm test
displayName: 'Run unit tests'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: 'dist'
ArtifactName: $(artifactName)
- stage: DeployStaging
displayName: 'Deploy to Staging'
dependsOn: Build
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
jobs:
- deployment: DeployJob
pool:
vmImage: 'ubuntu-latest'
environment: staging
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: $(artifactName)
- script: echo "Deploying artifact to staging server..."
displayName: 'Deploy step'
- script: echo "Running smoke tests..."
displayName: 'Smoke test'
ويبين هذا الخط:
- Trigger with path exclusion ] — documentation changes won't trigger a full build.
- Variables] defined at the top for reusability.
- Two stages] – Build (non- deployed) and DeployStaging ( deployed job). The deployment stage only runs if the source branch is and the build succeeded.
- Deployment job] using the keyword, which enables traceability, approvals, and gates.
- Artifact publishing and downloading] - the build output is save and later retrieved by the deployment stage.
تلاميذ متقدمون
المسافات المتعددة مع الموافقة على الدليل
(أزور ديفوبس يونام) تدعم البيئات بفحص يدوي للموافقة، ويمكنك أن تطلب من مستخدمين أو مجموعات محددة الموافقة على نشر قبل أن يمضي قدماً، وهذا تعريف في القانون العالمي لرصد حركة الشباب من خلال الإشارة إلى بيئة تم فيها الموافقة.
- stage: DeployProduction
dependsOn: DeployStaging
condition: succeeded()
jobs:
- deployment: ProdDeployment
pool:
vmImage: 'ubuntu-latest'
environment: production
strategy:
runOnce:
deploy:
steps:
- script: echo "Deploying to production..."
التنفيذ المشروط
Use expressions like to control which stages, jobs, or steps run. Azure DevOps supports a rich expression language with functions for string manipulation, logical operators, and collection checks.
استخدام الحاويات
وبدلاً من استخدام صورة عن طريق التصوير بالأشعة فوق البنفسجية، يمكن أن تدير وظائف كاملة داخل حاوية، وهذا مثالي لضمان وجود بيئات متسقة عبر التنمية واتفاقية مكافحة التصحر، ويحدّد ببساطة عنصراً ] في إطار العمل أو المجمع.
pool:
vmImage: 'ubuntu-latest'
container: node:18-alpine
أفضل الممارسات في مجال خط الأنابيب
واستنادا إلى عمليات الإنتاج، هنا ممارسات رئيسية لإبقاء خطوط الأنابيب الخاصة بك قوية وقابلة للاستمرار:
- Use templates liberally.] Extract common steps into parameterized templates. This reduces duplication and makes it easy to enforce standards (e.g., a security scan template that all projects must run).
- Keep YAML files small and focused.] A single monolithic file becomes hard to read and debug. Split into multiple files organized by stage or function (e.g., , , .
- Secure secrets with Azure Key Vault.] Avoid hardcoding passwords, API keys, or certificates. Useتغييرات groups linked to Key Vault, and reference them in your pipeline. Azure DevOps will automatically fetch the latest values at runtime.
- Validate YAML syntax before committing.] Use a linter or IDE plugin to catch indentation errors and missing key. Azure DevOps also provides a "Validate" blue in the pipeline editor.
- Name resources clearly.] Give stages, jobs, and steps meaningful values. This greatly improves readability in logs and visualizations.
- Use pipeline caching] to speed up builds. Cache dependencies like ] or NuGet packages to avoid re-downloading them on every run. Azure DevOps provides a task for this purpose.
- Implement early failure.] Fail the pipeline as quickly as possible. Run linting and syntax checks before expensive integration tests. Use the ] option in script tasks to catch warnings turned into errors.
- ]Document your pipeline.] Include comments in the YAML file explaining non-obvious choices, especially when using expressions or conditional logical. Consider maintaining a README alongside the pipeline files.
إدماج الأدوات الأخرى
:: دمج خطوط أنابيب " أزور ديفوبس يام " محلياً في العديد من الخدمات، وتشمل التكاملات المشتركة ما يلي:
- SonarQube] for continuous code quality inspection — add a SonarQubePrepare task before build and a SonarQubeAnalyze task after.
- Docker] for container builds – use the Docker@2 task to build and push images to Azure Container Registry or Docker Hub.
- GitHub] - YAML pipelines can be configured to work with GitHub repositories, not just Azure Repos. Simply select GitHub as your source during pipeline creation.
- ServiceNow] for change management – the ServiceNow Change Management extension allows pipelines to create and update change requests during deployments.
For a complete list of available tasks, refer to the Azure Pipelines Tasks] documentation.
الشلالات المشتركة وكيفية تجنبها
وحتى الأفرقة ذات الخبرة تصادف أحياناً مشاكل مع خطوط الأنابيب التابعة لليونام، ويقع أدناه أخطاء متكررة وحلول لها:
- Invalid YAML syntax - مقطورات، أماكن غير متجانسة للكشف (YAML لا تسمح بالتذاكر) - استخدام أداة التحقق في محررك أو في مقصورة شركة Azure DevOpss YAML.
- Un clear changing scoping] —تغييرات محددة على أعلى مستوى فوق متغيرات التجاوز/العمل ما لم تستخدمي النسيج الكلي على النحو الصحيح. Use for template expressions and for runtime evaluation.
- Misconfigured triggers] - forgetting to set a trigger results in the pipeline only running on manual or scheduled triggers.
- Ignoring agent pool capacity] – using a private agent pool without ensuring enough agents can cause delays or failures. Consider using Microsoft —hosted agents for better elsyity.
- Not testing pipeline changes] — always run a test build on a branch before merging to main. Even minor changes to templates can break dozens of pipelines silently.
خاتمة
تمثل خطوط الأنابيب التي تستخدمها شركة Azure DevOps YAML نهجاً ناضجاً ومضموناً في البداية إزاء مبادرة CI/CD يمتد من المشاريع الصغيرة إلى هندسة الإطلاق على مستوى المؤسسة، وبوضع تعريفات خط الأنابيب تحت رقابة النسخ، تحصل الأفرقة على الشفافية، وإعادة الإنتاج، وجسر لا يرقى بين التنمية والعمليات، وينطلق نظام YAML بشكل واضح بما يكفي لنموذج تدفقات العمل المعقدة، ومع ذلك ما يكفي من التنظيمات لا تزال قابلة للقراءة ومحافظة عندما تكون مقترنة مع أفضل الممارسات.
إن اعتماد خطوط الأنابيب التي تخضع لمراقبة النسخ ليس فقط بشأن التشغيل الآلي - بل يتعلق بمعالجة عملية التسليم بنفس الحزمة التي يُستخدم بها رمز التطبيقات، وبالنسبة للأفرقة التي تسعى إلى زيادة تواتر النشر، والحد من الأخطاء اليدوية، وتحسين التعاون، فإن خطوط الأنابيب التي تعمل على تطوير نظام Azure DevOps YAML هي أساس مثبت، بدءا بتحديد خط أنابيب بسيط لمشروعك، ثم إضافة مراحل، ونماذج، وتكاملات نضجك.