Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
SplitADOPipelines.agent.md165 linesDownload Raw Back to agents
1---2name: SplitADOPipelines3description: This agent will implement and restructure the repository's existing ADO pipelines into Official and NonOfficial pipelines.4tools: ['vscode', 'execute', 'read', 'agent', 'edit', 'search', 'todo']5---6 7This agent will implement and restructure the repository's existing ADO pipelines into Official and NonOfficial pipelines. 8 9A repository will have under the ./pipelines directory a series of yaml files that define the ADO pipelines for the repository.10 11First confirm if the pipelines are using a toggle switch for Official and NonOfficial. This will look something like this12 13```yaml14parameters:15  - name: templateFile16    value: ${{ iif ( parameters.OfficialBuild, 'v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates', 'v2/OneBranch.NonOfficial.CrossPlat.yml@onebranchTemplates' ) }}17```18 19Followed by:20 21```yaml22extends:23  template: ${{ variables.templateFile }}24```25 26This is an indicator that this work needs to be done. This toggle switch is no longer allowed and the templates need to be hard coded.27 28## Refactoring Steps29 30### Step 1: Extract Shared Templates31 32For each pipeline file that uses the toggle switch pattern (e.g., `PowerShell-Packages.yml`):33 341. Create a `./pipelines/templates` directory if it doesn't exist352. Extract the **variables section** into `./pipelines/templates/PowerShell-Packages-Variables.yml`363. Extract the **stages section** into `./pipelines/templates/PowerShell-Packages-Stages.yml`37 38**IMPORTANT**: Only extract the `variables:` and `stages:` sections. All other sections (parameters, resources, extends, etc.) remain in the pipeline files.39 40### Step 2: Create Official Pipeline (In-Place Refactoring)41 42The original toggle-based file becomes the Official pipeline:43 441. **Keep the file in its original location** (e.g., `./pipelines/PowerShell-Packages.yml` stays where it is)452. Remove the toggle switch parameter (`templateFile` parameter)463. Hard-code the Official template reference:47   ```yaml48   extends:49     template: v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates50   ```514. Replace the `variables:` section with a template reference:52   ```yaml53   variables:54     - template: templates/PowerShell-Packages-Variables.yml55   ```565. Replace the `stages:` section with a template reference:57   ```yaml58   stages:59     - template: templates/PowerShell-Packages-Stages.yml60   ```61 62### Step 3: Create NonOfficial Pipeline63 641. Create `./pipelines/NonOfficial` directory if it doesn't exist652. Create the NonOfficial pipeline file (e.g., `./pipelines/NonOfficial/PowerShell-Packages-NonOfficial.yml`)663. Copy the structure from the refactored Official pipeline674. Hard-code the NonOfficial template reference:68   ```yaml69   extends:70     template: v2/OneBranch.NonOfficial.CrossPlat.yml@onebranchTemplates71   ```725. Reference the same shared templates:73   ```yaml74   variables:75     - template: ../templates/PowerShell-Packages-Variables.yml76   77   stages:78     - template: ../templates/PowerShell-Packages-Stages.yml79   ```80 81**Note**: The NonOfficial pipeline uses `../templates/` because it's one directory deeper than the Official pipeline.82 83### Step 4: Link NonOfficial Pipelines to NonOfficial Dependencies84 85After creating NonOfficial pipelines, ensure they consume artifacts from other **NonOfficial** pipelines, not Official ones.86 871. **Check the `resources:` section** in each NonOfficial pipeline for `pipelines:` dependencies882. **Identify Official pipeline references** that need to be changed to NonOfficial893. **Update the `source:` field** to point to the NonOfficial version90 91**Example Problem:** NonOfficial pipeline pointing to Official dependency92```yaml93resources:94  pipelines:95    - pipeline: CoOrdinatedBuildPipeline96      source: 'PowerShell-Coordinated Binaries-Official'  # ❌ Wrong - Official!97```98 99**Solution:** Update to NonOfficial dependency100```yaml101resources:102  pipelines:103    - pipeline: CoOrdinatedBuildPipeline104      source: 'PowerShell-Coordinated Binaries-NonOfficial'  # ✅ Correct - NonOfficial!105```106 107**IMPORTANT**: The `source:` field must match the **exact ADO pipeline definition name** as it appears in Azure DevOps, not necessarily the file name.108 109### Step 5: Configure Release Environment Parameters (NonAzure Only)110 111**This step only applies if the pipeline uses `category: NonAzure` in the release configuration.**112 113If you detect this pattern in the original pipeline:114 115```yaml116extends:117  template: v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates  # or NonOfficial118  parameters:119    release:120      category: NonAzure121```122 123Then you must configure the `ob_release_environment` parameter when referencing the stages template.124 125#### Official Pipeline Configuration126 127In the Official pipeline (e.g., `./pipelines/PowerShell-Packages.yml`):128 129```yaml130stages:131  - template: templates/PowerShell-Packages-Stages.yml132    parameters:133      ob_release_environment: Production134```135 136#### NonOfficial Pipeline Configuration137 138In the NonOfficial pipeline (e.g., `./pipelines/NonOfficial/PowerShell-Packages-NonOfficial.yml`):139 140```yaml141stages:142  - template: ../templates/PowerShell-Packages-Stages.yml143    parameters:144      ob_release_environment: Test145```146 147#### Update Stages Template to Accept Parameter148 149The extracted stages template (e.g., `./pipelines/templates/PowerShell-Packages-Stages.yml`) must declare the parameter at the top:150 151```yaml152parameters:153  - name: ob_release_environment154    type: string155 156stages:157  # ... rest of stages configuration using ${{ parameters.ob_release_environment }}158```159 160**IMPORTANT**: 161- Only configure this for pipelines with `category: NonAzure`162- Official pipelines always use `ob_release_environment: Production`163- NonOfficial pipelines always use `ob_release_environment: Test`164- The stages template must accept this parameter and use it in the appropriate stage configurations165