$npx -y skills add BagelHole/DevOps-Security-Agent-Skills --skill azure-devopsSet up Azure Pipelines for CI/CD, configure build and release pipelines, manage Azure DevOps projects, and integrate with Azure services. Use when working with Azure DevOps Services or Server for enterprise DevOps workflows.
| 1 | # Azure DevOps Pipelines |
| 2 | |
| 3 | Build, test, and deploy applications using Azure Pipelines with YAML or classic editor. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | Use this skill when: |
| 8 | - Creating CI/CD pipelines in Azure DevOps |
| 9 | - Configuring build and release stages |
| 10 | - Managing Azure DevOps service connections |
| 11 | - Deploying to Azure or other cloud platforms |
| 12 | - Setting up multi-stage YAML pipelines |
| 13 | |
| 14 | ## Prerequisites |
| 15 | |
| 16 | - Azure DevOps organization and project |
| 17 | - Service connections for target environments |
| 18 | - Basic YAML understanding |
| 19 | - Azure subscription (for Azure deployments) |
| 20 | |
| 21 | ## YAML Pipeline Structure |
| 22 | |
| 23 | Create `azure-pipelines.yml` in repository root: |
| 24 | |
| 25 | ```yaml |
| 26 | trigger: |
| 27 | branches: |
| 28 | include: |
| 29 | - main |
| 30 | - develop |
| 31 | paths: |
| 32 | include: |
| 33 | - src/* |
| 34 | |
| 35 | pool: |
| 36 | vmImage: 'ubuntu-latest' |
| 37 | |
| 38 | variables: |
| 39 | buildConfiguration: 'Release' |
| 40 | nodeVersion: '20.x' |
| 41 | |
| 42 | stages: |
| 43 | - stage: Build |
| 44 | jobs: |
| 45 | - job: BuildJob |
| 46 | steps: |
| 47 | - task: NodeTool@0 |
| 48 | inputs: |
| 49 | versionSpec: $(nodeVersion) |
| 50 | - script: | |
| 51 | npm ci |
| 52 | npm run build |
| 53 | displayName: 'Build application' |
| 54 | - publish: $(Build.ArtifactStagingDirectory) |
| 55 | artifact: drop |
| 56 | |
| 57 | - stage: Deploy |
| 58 | dependsOn: Build |
| 59 | condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) |
| 60 | jobs: |
| 61 | - deployment: DeployWeb |
| 62 | environment: 'production' |
| 63 | strategy: |
| 64 | runOnce: |
| 65 | deploy: |
| 66 | steps: |
| 67 | - script: echo Deploying to production |
| 68 | ``` |
| 69 | |
| 70 | ## Triggers |
| 71 | |
| 72 | ### Branch Triggers |
| 73 | |
| 74 | ```yaml |
| 75 | trigger: |
| 76 | branches: |
| 77 | include: |
| 78 | - main |
| 79 | - release/* |
| 80 | exclude: |
| 81 | - feature/* |
| 82 | tags: |
| 83 | include: |
| 84 | - v* |
| 85 | ``` |
| 86 | |
| 87 | ### Pull Request Triggers |
| 88 | |
| 89 | ```yaml |
| 90 | pr: |
| 91 | branches: |
| 92 | include: |
| 93 | - main |
| 94 | paths: |
| 95 | include: |
| 96 | - src/* |
| 97 | exclude: |
| 98 | - docs/* |
| 99 | ``` |
| 100 | |
| 101 | ### Scheduled Triggers |
| 102 | |
| 103 | ```yaml |
| 104 | schedules: |
| 105 | - cron: '0 2 * * *' |
| 106 | displayName: 'Nightly build' |
| 107 | branches: |
| 108 | include: |
| 109 | - main |
| 110 | always: true |
| 111 | ``` |
| 112 | |
| 113 | ## Jobs and Stages |
| 114 | |
| 115 | ### Parallel Jobs |
| 116 | |
| 117 | ```yaml |
| 118 | stages: |
| 119 | - stage: Test |
| 120 | jobs: |
| 121 | - job: UnitTests |
| 122 | pool: |
| 123 | vmImage: 'ubuntu-latest' |
| 124 | steps: |
| 125 | - script: npm run test:unit |
| 126 | |
| 127 | - job: IntegrationTests |
| 128 | pool: |
| 129 | vmImage: 'ubuntu-latest' |
| 130 | steps: |
| 131 | - script: npm run test:integration |
| 132 | ``` |
| 133 | |
| 134 | ### Matrix Strategy |
| 135 | |
| 136 | ```yaml |
| 137 | jobs: |
| 138 | - job: Build |
| 139 | strategy: |
| 140 | matrix: |
| 141 | linux: |
| 142 | vmImage: 'ubuntu-latest' |
| 143 | windows: |
| 144 | vmImage: 'windows-latest' |
| 145 | mac: |
| 146 | vmImage: 'macos-latest' |
| 147 | pool: |
| 148 | vmImage: $(vmImage) |
| 149 | steps: |
| 150 | - script: npm test |
| 151 | ``` |
| 152 | |
| 153 | ### Job Dependencies |
| 154 | |
| 155 | ```yaml |
| 156 | stages: |
| 157 | - stage: Build |
| 158 | jobs: |
| 159 | - job: A |
| 160 | steps: |
| 161 | - script: echo Job A |
| 162 | - job: B |
| 163 | dependsOn: A |
| 164 | steps: |
| 165 | - script: echo Job B |
| 166 | ``` |
| 167 | |
| 168 | ## Variables and Parameters |
| 169 | |
| 170 | ### Variable Groups |
| 171 | |
| 172 | ```yaml |
| 173 | variables: |
| 174 | - group: 'production-secrets' |
| 175 | - name: buildConfiguration |
| 176 | value: 'Release' |
| 177 | ``` |
| 178 | |
| 179 | ### Runtime Parameters |
| 180 | |
| 181 | ```yaml |
| 182 | parameters: |
| 183 | - name: environment |
| 184 | displayName: 'Environment' |
| 185 | type: string |
| 186 | default: 'dev' |
| 187 | values: |
| 188 | - dev |
| 189 | - staging |
| 190 | - prod |
| 191 | |
| 192 | stages: |
| 193 | - stage: Deploy |
| 194 | variables: |
| 195 | env: ${{ parameters.environment }} |
| 196 | jobs: |
| 197 | - job: Deploy |
| 198 | steps: |
| 199 | - script: echo "Deploying to $(env)" |
| 200 | ``` |
| 201 | |
| 202 | ### Secret Variables |
| 203 | |
| 204 | ```yaml |
| 205 | variables: |
| 206 | - name: mySecret |
| 207 | value: $(SECRET_FROM_PIPELINE) # Set in pipeline settings |
| 208 | |
| 209 | steps: |
| 210 | - script: | |
| 211 | echo "Using secret" |
| 212 | ./deploy.sh |
| 213 | env: |
| 214 | API_KEY: $(mySecret) |
| 215 | ``` |
| 216 | |
| 217 | ## Templates |
| 218 | |
| 219 | ### Job Template |
| 220 | |
| 221 | ```yaml |
| 222 | # templates/build-job.yml |
| 223 | parameters: |
| 224 | - name: nodeVersion |
| 225 | default: '20' |
| 226 | |
| 227 | jobs: |
| 228 | - job: Build |
| 229 | steps: |
| 230 | - task: NodeTool@0 |
| 231 | inputs: |
| 232 | versionSpec: ${{ parameters.nodeVersion }} |
| 233 | - script: npm ci && npm run build |
| 234 | ``` |
| 235 | |
| 236 | ### Using Templates |
| 237 | |
| 238 | ```yaml |
| 239 | # azure-pipelines.yml |
| 240 | stages: |
| 241 | - stage: Build |
| 242 | jobs: |
| 243 | - template: templates/build-job.yml |
| 244 | parameters: |
| 245 | nodeVersion: '20' |
| 246 | ``` |
| 247 | |
| 248 | ### Stage Template |
| 249 | |
| 250 | ```yaml |
| 251 | # templates/deploy-stage.yml |
| 252 | parameters: |
| 253 | - name: environment |
| 254 | type: string |
| 255 | - name: serviceConnection |
| 256 | type: string |
| 257 | |
| 258 | stages: |
| 259 | - stage: Deploy_${{ parameters.environment }} |
| 260 | jobs: |
| 261 | - deployment: Deploy |
| 262 | environment: ${{ parameters.environment }} |
| 263 | strategy: |
| 264 | runOnce: |
| 265 | deploy: |
| 266 | steps: |
| 267 | - task: AzureWebApp@1 |
| 268 | inputs: |
| 269 | azureSubscription: ${{ parameters.serviceConnection }} |
| 270 | appName: 'my |