home / skills / ntaksh42 / agents / azure-pipelines-generator

azure-pipelines-generator skill

/.claude/skills/azure-pipelines-generator

This skill generates Azure Pipelines YAML for multi-stage CI/CD, enabling reusable templates and conditional deployments across Dev, Staging, and Production.

npx playbooks add skill ntaksh42/agents --skill azure-pipelines-generator

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
8.2 KB
---
name: azure-pipelines-generator
description: Generate Azure Pipelines YAML for CI/CD with multi-stage builds and deployments. Use when creating Azure DevOps pipelines or automating builds.
---

# Azure Pipelines Generator Skill

Azure PipelinesのYAML定義を生成するスキルです。

## 概要

CI/CDパイプラインをAzure Pipelines YAML形式で自動生成します。

## 主な機能

- **ビルドパイプライン**: CI設定
- **リリースパイプライン**: CD設定
- **マルチステージ**: ステージ分割
- **テンプレート**: 再利用可能な設定
- **条件付き実行**: ブランチ、タグ条件
- **環境デプロイ**: Dev、Staging、Production

## 基本パイプライン

### Node.js アプリケーション

```yaml
# azure-pipelines.yml
trigger:
  branches:
    include:
      - main
      - develop
  paths:
    exclude:
      - docs/*
      - README.md

pool:
  vmImage: 'ubuntu-latest'

variables:
  nodeVersion: '18.x'
  buildConfiguration: 'Release'

stages:
  - stage: Build
    displayName: 'Build and Test'
    jobs:
      - job: BuildJob
        displayName: 'Build Application'
        steps:
          - task: NodeTool@0
            displayName: 'Install Node.js'
            inputs:
              versionSpec: $(nodeVersion)

          - task: Npm@1
            displayName: 'npm install'
            inputs:
              command: 'install'

          - task: Npm@1
            displayName: 'npm run build'
            inputs:
              command: 'custom'
              customCommand: 'run build'

          - task: Npm@1
            displayName: 'npm test'
            inputs:
              command: 'custom'
              customCommand: 'test'

          - task: PublishTestResults@2
            displayName: 'Publish Test Results'
            condition: succeededOrFailed()
            inputs:
              testResultsFormat: 'JUnit'
              testResultsFiles: '**/test-results.xml'

          - task: PublishCodeCoverageResults@1
            displayName: 'Publish Code Coverage'
            inputs:
              codeCoverageTool: 'Cobertura'
              summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml'

          - task: PublishBuildArtifacts@1
            displayName: 'Publish Artifact: dist'
            inputs:
              PathtoPublish: '$(Build.SourcesDirectory)/dist'
              ArtifactName: 'dist'

  - stage: Deploy_Dev
    displayName: 'Deploy to Development'
    dependsOn: Build
    condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))
    jobs:
      - deployment: DeployDev
        displayName: 'Deploy to Dev'
        environment: 'Development'
        strategy:
          runOnce:
            deploy:
              steps:
                - task: DownloadBuildArtifacts@0
                  inputs:
                    artifactName: 'dist'

                - task: AzureWebApp@1
                  displayName: 'Deploy to Azure Web App'
                  inputs:
                    azureSubscription: 'Azure-Connection'
                    appType: 'webAppLinux'
                    appName: 'myapp-dev'
                    package: '$(System.ArtifactsDirectory)/dist'

  - stage: Deploy_Prod
    displayName: 'Deploy to Production'
    dependsOn: Build
    condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
    jobs:
      - deployment: DeployProd
        displayName: 'Deploy to Production'
        environment: 'Production'
        strategy:
          runOnce:
            deploy:
              steps:
                - task: DownloadBuildArtifacts@0
                  inputs:
                    artifactName: 'dist'

                - task: AzureWebApp@1
                  displayName: 'Deploy to Azure Web App'
                  inputs:
                    azureSubscription: 'Azure-Connection'
                    appType: 'webAppLinux'
                    appName: 'myapp-prod'
                    package: '$(System.ArtifactsDirectory)/dist'
```

### .NET アプリケーション

```yaml
trigger:
  - main

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

stages:
  - stage: Build
    jobs:
      - job: Build
        steps:
          - task: NuGetToolInstaller@1

          - task: NuGetCommand@2
            inputs:
              restoreSolution: '$(solution)'

          - task: VSBuild@1
            inputs:
              solution: '$(solution)'
              msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
              platform: '$(buildPlatform)'
              configuration: '$(buildConfiguration)'

          - task: VSTest@2
            inputs:
              platform: '$(buildPlatform)'
              configuration: '$(buildConfiguration)'

          - task: PublishBuildArtifacts@1
            inputs:
              PathtoPublish: '$(Build.ArtifactStagingDirectory)'
              ArtifactName: 'drop'
```

### Docker ビルド & プッシュ

```yaml
trigger:
  - main

pool:
  vmImage: 'ubuntu-latest'

variables:
  dockerRegistryServiceConnection: 'MyDockerRegistry'
  imageRepository: 'myapp'
  containerRegistry: 'myregistry.azurecr.io'
  dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
  tag: '$(Build.BuildId)'

stages:
  - stage: Build
    jobs:
      - job: BuildAndPush
        steps:
          - task: Docker@2
            displayName: 'Build Docker Image'
            inputs:
              command: build
              repository: $(imageRepository)
              dockerfile: $(dockerfilePath)
              containerRegistry: $(dockerRegistryServiceConnection)
              tags: |
                $(tag)
                latest

          - task: Docker@2
            displayName: 'Push Docker Image'
            inputs:
              command: push
              repository: $(imageRepository)
              containerRegistry: $(dockerRegistryServiceConnection)
              tags: |
                $(tag)
                latest

  - stage: Deploy
    dependsOn: Build
    jobs:
      - deployment: DeployToAKS
        environment: 'kubernetes-prod'
        strategy:
          runOnce:
            deploy:
              steps:
                - task: KubernetesManifest@0
                  displayName: 'Deploy to AKS'
                  inputs:
                    action: 'deploy'
                    kubernetesServiceConnection: 'AKS-Connection'
                    namespace: 'production'
                    manifests: |
                      $(Pipeline.Workspace)/manifests/deployment.yml
                      $(Pipeline.Workspace)/manifests/service.yml
                    containers: '$(containerRegistry)/$(imageRepository):$(tag)'
```

## テンプレート使用

### メインパイプライン

```yaml
# azure-pipelines.yml
trigger:
  - main

resources:
  repositories:
    - repository: templates
      type: git
      name: PipelineTemplates
      ref: refs/heads/main

stages:
  - template: templates/build-template.yml@templates
    parameters:
      nodeVersion: '18.x'

  - template: templates/deploy-template.yml@templates
    parameters:
      environment: 'Production'
      appName: 'myapp-prod'
```

### ビルドテンプレート

```yaml
# templates/build-template.yml
parameters:
  - name: nodeVersion
    type: string
    default: '18.x'

jobs:
  - job: Build
    pool:
      vmImage: 'ubuntu-latest'
    steps:
      - task: NodeTool@0
        inputs:
          versionSpec: ${{ parameters.nodeVersion }}

      - script: |
          npm install
          npm run build
          npm test
        displayName: 'Build and Test'
```

## PR トリガー

```yaml
# PR validation
pr:
  branches:
    include:
      - main
      - develop
  paths:
    exclude:
      - docs/*

trigger: none

pool:
  vmImage: 'ubuntu-latest'

steps:
  - task: Npm@1
    displayName: 'npm install'
    inputs:
      command: 'install'

  - task: Npm@1
    displayName: 'Run linter'
    inputs:
      command: 'custom'
      customCommand: 'run lint'

  - task: Npm@1
    displayName: 'Run tests'
    inputs:
      command: 'custom'
      customCommand: 'test'
```

## バージョン情報

- スキルバージョン: 1.0.0
- 最終更新: 2025-01-22

Overview

This skill generates Azure Pipelines YAML for CI/CD with multi-stage builds and deployments. It produces ready-to-use pipeline definitions for Node.js, .NET, Docker, and template-driven workflows. Use it to automate CI builds, run tests, publish artifacts, and deploy to environments like Dev, Staging, Production, AKS, or Azure Web Apps. The output supports branch and PR triggers, conditional stages, and reusable templates.

How this skill works

Provide project details and target environments, and the skill emits Azure Pipelines YAML tailored to the stack and workflow you choose. It can create single-file multi-stage pipelines or split logic into referenced templates for reuse. Generated pipelines include build, test, artifact publish, environment deployments, Docker image build-and-push, and optional PR validation steps. Variables, conditions, and service connection placeholders are included for easy customization and integration with Azure resources.

When to use it

  • Setting up CI/CD for Node.js, .NET, or containerized applications in Azure DevOps.
  • Creating multi-stage YAML pipelines that include build, test, artifact publishing, and environment deployments.
  • Standardizing pipelines across projects using reusable templates and shared template repositories.
  • Adding automated PR checks, branch-based conditional deployments, or environment-specific deploy stages.
  • Automating Docker image build and push workflows and deploying to AKS or Azure Web Apps.

Best practices

  • Parameterize sensitive values and use Azure DevOps service connections for credentials rather than hard-coding.
  • Use templates for common build and deploy logic to keep pipelines DRY and easier to maintain.
  • Include test and code-coverage publishing steps to make quality gates visible in the pipeline.
  • Employ branch and PR triggers to validate changes before merges, and restrict production deploys to protected branches.
  • Store pipeline manifests and Kubernetes manifests in the repository or a referenced templates repo for traceability.

Example use cases

  • Generate a Node.js multi-stage pipeline that builds, tests, publishes artifacts, and deploys to Dev and Prod based on branch.
  • Create a .NET pipeline that restores NuGet packages, builds solutions, runs VSTest, and produces build artifacts for release.
  • Build-and-push Docker image pipelines that tag by build ID and deploy manifests to AKS using KubernetesManifest task.
  • Assemble a main pipeline that references shared build and deploy templates from a templates repository.
  • Add PR validation pipeline that lints code, runs tests, and prevents merges if checks fail.

FAQ

Can I customize generated service connection names and resource names?

Yes. The generator includes placeholders for service connections, app names, registries, and resource names so you can replace them with your exact Azure DevOps service connections and resource identifiers.

Does the skill support template-based pipelines?

Yes. It can emit a main pipeline that references build and deploy templates in a templates repo, with parameter passing for node versions, app names, and environments.