Azure-DevOps-Integration
Kopiere einen Setup-Prompt mit den Installationsschritten und dem vollständigen Markdown-Guide für dieses Plugin.
Integriere Capgo Live Updates mit Azure DevOps Pipelines, um deine App-Updates automatisch zu deployen, sobald du code-Änderungen pushst. Dieser Guide zeigt dir, wie du automatisierte Build-, Test- und Deployment-Workflows einrichtest.
Voraussetzungen
Abschnitt: „Voraussetzungen“Stelle vor der Einrichtung der Azure DevOps-Integration sicher, dass du Folgendes hast:
- Eine Azure DevOps-Organisation und ein Projekt
- Ein Capgo-Konto mit einer konfigurierten App
- Ihre App-Quelldateien code in einem Azure Repos Git-Repository
- Node.js und npm/yarn in deinem Projekt konfiguriert
Azure DevOps-Pipeline einrichten
Abschnitt: „Azure DevOps Pipeline einrichten“Schritt 1: Pipeline-Variablen erstellen
Abschnitt: „Schritt 1: Pipeline-Variablen erstellen“Legen Sie zuerst die erforderlichen Variablen in Ihrem Azure DevOps-Projekt an:
- Navigieren Sie zu Ihrem Azure DevOps-Projekt
- Gehe zu Pipelines → Bibliothek → Variablengruppen
- Erstellen Sie eine neue Variablengruppe namens
Capgo-Variables - Füge die folgenden Variablen hinzu:
| Variablenname | Wert | Sicher |
|---|---|---|
CAPGO_TOKEN | Dein Capgo API Token | ✅ Ja |
Einfach
Abschnitt „Einfach“Basiskonfiguration, die bei jedem Push auf den main-Branch in die Produktion deployt:
# Simple Azure DevOps Pipeline for Capgo Live Updatestrigger: branches: include: - main
variables: - group: Capgo-Variables
jobs: - job: BuildAndDeploy displayName: 'Build and Deploy to Capgo' pool: vmImage: 'ubuntu-latest'
steps: - task: NodeTool@0 displayName: 'Setup Node.js' inputs: versionSpec: '22.x'
- script: | npm ci npm run test npm run build displayName: 'Install, test and build'
- script: | npm install -g @capgo/cli npx @capgo/cli bundle upload --apikey $(CAPGO_TOKEN) --channel production displayName: 'Deploy to Capgo'Erweitert
Abschnitt „Erweitert“Feature-Branch-Deployments
Abschnitt: „Feature-Branch-Deployments“Deploye Feature-Branches in Test-Channels für Review und Tests:
# Feature branch deploymenttrigger: branches: include: - feature/*
variables: - group: Capgo-Variables
jobs: - job: DeployFeature displayName: 'Deploy Feature Branch' pool: vmImage: 'ubuntu-latest' condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/feature/')
steps: - task: NodeTool@0 inputs: versionSpec: '22.x'
- script: | npm ci npm run test npm run build displayName: 'Install, test and build'
- script: | BRANCH_NAME=$(echo "$(Build.SourceBranchName)" | sed 's/[^a-zA-Z0-9-]/-/g') CHANNEL_NAME="feature-$BRANCH_NAME" npm install -g @capgo/cli npx @capgo/cli channel add $CHANNEL_NAME --apikey $(CAPGO_TOKEN) || true npx @capgo/cli bundle upload --apikey $(CAPGO_TOKEN) --channel $CHANNEL_NAME displayName: 'Deploy to Feature Channel'Verschlüsselung nutzen
Abschnitt: „Verschlüsselung nutzen“If you’re using die Verschlüsselungsfunktion von Capgonutzt, musst du deinen Private Key sicher in deiner CI/CD-Umgebung speichern.
Danach Verschlüsselungsschlüssel einrichten lokal nutzt, füge deinen privaten Schlüssel den Azure DevOps-Variablen hinzu:
# Display your private key content (copy this output)cat .capgo_key_v2Füge diesen Inhalt als CAPGO_PRIVATE_KEY in Ihrer Azure DevOps-Variablengruppe (als Geheimnis markieren) und nutzen Sie sie in Pipelines:
# Deploy with encryption- script: | npm install -g @capgo/cli npx @capgo/cli bundle upload --apikey $(CAPGO_TOKEN) --key-data-v2 "$(CAPGO_PRIVATE_KEY)" --channel production displayName: 'Deploy to Capgo with Encryption'Multi-Channel-Konfiguration
Abschnitt mit dem Titel „Multi-Channel-Konfiguration“Für umfassende Informationen zur Einrichtung und Verwaltung mehrerer Deployment-Channels lesen Sie die Channels-Dokumentation.
Vollständige Konfiguration mit mehreren Umgebungen und Pull-Request-Deployments:
# Advanced Azure DevOps Pipeline with Multiple Channelstrigger: branches: include: - main - develop
pr: branches: include: - main - develop
variables: - group: Capgo-Variables
stages: # Build stage - stage: Build jobs: - job: BuildApp pool: vmImage: 'ubuntu-latest' steps: - task: NodeTool@0 inputs: versionSpec: '22.x'
- script: | npm ci npm run test npm run build displayName: 'Install, test and build'
- task: PublishBuildArtifacts@1 inputs: pathToPublish: 'dist' artifactName: 'app-build'
# Deploy to development - stage: DeployDev condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')) jobs: - deployment: DeployDevelopment environment: development pool: vmImage: 'ubuntu-latest' strategy: runOnce: deploy: steps: - task: NodeTool@0 inputs: versionSpec: '22.x'
- task: DownloadBuildArtifacts@0 inputs: artifactName: 'app-build' downloadPath: '$(Pipeline.Workspace)'
- script: | npm install -g @capgo/cli npx @capgo/cli bundle upload --apikey $(CAPGO_TOKEN) --channel development --path $(Pipeline.Workspace)/app-build displayName: 'Deploy to Development'
# Deploy PR to test channel - stage: DeployPR condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest')) jobs: - job: DeployPRChannel pool: vmImage: 'ubuntu-latest' steps: - task: NodeTool@0 inputs: versionSpec: '22.x'
- task: DownloadBuildArtifacts@0 inputs: artifactName: 'app-build' downloadPath: '$(Pipeline.Workspace)'
- script: | CHANNEL_NAME="pr-$(System.PullRequest.PullRequestNumber)" npm install -g @capgo/cli npx @capgo/cli channel add $CHANNEL_NAME --apikey $(CAPGO_TOKEN) || true npx @capgo/cli bundle upload --apikey $(CAPGO_TOKEN) --channel $CHANNEL_NAME --path $(Pipeline.Workspace)/app-build displayName: 'Deploy to PR Channel'
# Deploy to production - stage: DeployProd condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) jobs: - deployment: DeployProduction environment: production pool: vmImage: 'ubuntu-latest' strategy: runOnce: deploy: steps: - task: NodeTool@0 inputs: versionSpec: '22.x'
- task: DownloadBuildArtifacts@0 inputs: artifactName: 'app-build' downloadPath: '$(Pipeline.Workspace)'
- script: | npm install -g @capgo/cli npx @capgo/cli bundle upload --apikey $(CAPGO_TOKEN) --channel production --path $(Pipeline.Workspace)/app-build displayName: 'Deploy to Production'Deployment über mehrere Umgebungen hinweg
Abschnitt mit dem Titel „Multi-Environment Deployment“Für komplexe Szenarien mit mehreren Umgebungen:
# Extended pipeline with multiple environmentsparameters: - name: deployEnvironment displayName: 'Deploy Environment' type: string default: 'staging' values: - staging - production
variables: - group: Capgo-Variables - name: channelName ${{ if eq(parameters.deployEnvironment, 'production') }}: value: 'production' ${{ else }}: value: 'staging'
stages: # Build stage - stage: Build jobs: - job: BuildApp pool: vmImage: 'ubuntu-latest' steps: - task: NodeTool@0 inputs: versionSpec: '22.x'
- script: | npm ci npm run test npm run build displayName: 'Install, test and build'
- task: PublishBuildArtifacts@1 inputs: pathToPublish: 'dist' artifactName: 'app-build'
- stage: DeployStaging displayName: 'Deploy to Staging' dependsOn: Build condition: and(succeeded(), eq('${{ parameters.deployEnvironment }}', 'staging')) jobs: - deployment: DeployStaging displayName: 'Deploy to Staging Channel' pool: vmImage: 'ubuntu-latest' environment: 'staging' strategy: runOnce: deploy: steps: - template: deploy-steps.yml parameters: channel: 'staging'
- stage: DeployProduction displayName: 'Deploy to Production' dependsOn: Build condition: and(succeeded(), eq('${{ parameters.deployEnvironment }}', 'production')) jobs: - deployment: DeployProduction displayName: 'Deploy to Production Channel' pool: vmImage: 'ubuntu-latest' environment: 'production' strategy: runOnce: deploy: steps: - template: deploy-steps.yml parameters: channel: 'production'Deployment-Vorlage (deploy-steps.yml)
Abschnitt mit dem Titel „Deployment-Vorlage (deploy-steps.yml)“Erstellen Sie eine wiederverwendbare Vorlagendatei deploy-steps.yml:
parameters: - name: channel type: string
steps: - task: NodeTool@0 displayName: 'Install Node.js' inputs: versionSpec: '22.x'
- task: DownloadBuildArtifacts@0 displayName: 'Download build artifacts' inputs: artifactName: 'app-build' downloadPath: '$(System.ArtifactsDirectory)'
- script: | npm install -g @capgo/cli displayName: 'Install Capgo CLI'
- script: | npx @capgo/cli bundle upload \ --apikey $(CAPGO_TOKEN) \ --channel ${{ parameters.channel }} \ --path $(System.ArtifactsDirectory)/app-build displayName: 'Upload to Capgo (${{ parameters.channel }})'Branch-basierte Deployment-Strategie
Abschnitt: „Branch-basierte Deployment-Strategie“Konfigurieren Sie verschiedene Deployment-Strategien basierend auf Git-Branches:
trigger: branches: include: - main - develop - feature/*
variables: - group: Capgo-Variables - name: targetChannel ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/main') }}: value: 'production' ${{ elseif eq(variables['Build.SourceBranch'], 'refs/heads/develop') }}: value: 'staging' ${{ else }}: value: 'development'
stages: - stage: Build jobs: - job: BuildApp pool: vmImage: 'ubuntu-latest' steps: - task: NodeTool@0 inputs: versionSpec: '22.x'
- script: | npm ci npm run test npm run build displayName: 'Install, test and build'
- task: PublishBuildArtifacts@1 inputs: pathToPublish: 'dist' artifactName: 'app-build'
- stage: Deploy displayName: 'Deploy to $(targetChannel)' dependsOn: Build condition: succeeded() jobs: - deployment: DeployJob displayName: 'Deploy to $(targetChannel) Channel' pool: vmImage: 'ubuntu-latest' environment: '$(targetChannel)' strategy: runOnce: deploy: steps: - template: deploy-steps.yml parameters: channel: '$(targetChannel)'Sicherheits-Best-Practices
Abschnitt mit dem Titel „Security Best Practices“Sichere Variablenverwaltung
Abschnitt mit dem Titel „Sichere Variablenverwaltung“- Variable Groups verwenden: Speichern Sie sensible Daten in Azure DevOps Variable Groups
- Als Secret markieren: Markieren Sie API-Tokens und -Keys immer als Secret-Variablen
- Zugriffsbereich: Zugriff auf Variablengruppen auf bestimmte Pipelines und Benutzer beschränken
- Schlüssel rotieren: Capgo API-Tokens regelmäßig rotieren
Monitoring und Benachrichtigungen
Abschnitt mit dem Titel „Monitoring und Benachrichtigungen“Teams-Integration
Abschnitt mit dem Titel „Teams-Integration“Füge Microsoft-Teams-Benachrichtigungen zu deiner Pipeline hinzu:
- task: ms-teams-deploy-card@1.4.1 displayName: 'Notify Teams on Success' condition: succeeded() inputs: webhookUri: '$(TEAMS_WEBHOOK_URL)' title: 'Capgo Deployment Successful' text: 'App deployed to $(targetChannel) channel' themeColor: '00FF00'
- task: ms-teams-deploy-card@1.4.1 displayName: 'Notify Teams on Failure' condition: failed() inputs: webhookUri: '$(TEAMS_WEBHOOK_URL)' title: 'Capgo Deployment Failed' text: 'Deployment to $(targetChannel) failed' themeColor: 'FF0000'E-Mail-Benachrichtigungen
Abschnitt mit dem Titel „E-Mail-Benachrichtigungen“Konfiguriere E-Mail-Benachrichtigungen für den Deployment-Status:
- task: EmailReport@1 displayName: 'Send Email Report' condition: always() inputs: sendMailConditionConfig: 'Always' subject: 'Capgo Deployment Report - $(Build.BuildNumber)' to: 'team@yourcompany.com' body: | Deployment Status: $(Agent.JobStatus) Channel: $(targetChannel) Build: $(Build.BuildNumber) Commit: $(Build.SourceVersion)Fehlerbehebung
Abschnitt mit dem Titel „Troubleshooting“Häufige Probleme
Abschnitt „Häufige Probleme“Pipeline schlägt fehl mit „Capgo CLI not found“:
# Ensure global installation- script: | npm install -g @capgo/cli which capgo || echo "Capgo CLI not found in PATH" displayName: 'Install and verify Capgo CLI'Authentifizierungsfehler:
# Verify token is correctly set- script: | echo "Token length: ${#CAPGO_TOKEN}" if [ -z "$CAPGO_TOKEN" ]; then echo "CAPGO_TOKEN is not set" exit 1 fi displayName: 'Verify Capgo token' env: CAPGO_TOKEN: $(CAPGO_TOKEN)Build-Artefakte nicht gefunden:
# List available artifacts for debugging- script: | ls -la $(System.ArtifactsDirectory) find $(System.ArtifactsDirectory) -name "*.js" -o -name "*.html" displayName: 'Debug artifacts'Pipeline debuggen
Abschnitt mit dem Titel „Pipeline debuggen“Füge Debugging-Schritte hinzu, um Probleme zu beheben:
- script: | echo "Build.SourceBranch: $(Build.SourceBranch)" echo "Build.BuildNumber: $(Build.BuildNumber)" echo "Target Channel: $(targetChannel)" displayName: 'Debug Pipeline Variables'
- script: | npx @capgo/cli app debug --apikey $(CAPGO_TOKEN) displayName: 'Debug Capgo App Status'Nächste Schritte
Abschnitt „Nächste Schritte“- Mehr über Kanäle um verschiedene Deployment-Umgebungen zu verwalten
- Entdecken Eigener Speicher für fortgeschrittene Deployment-Szenarien
- Einrichten Verschlüsselung für sichere Deployments
- Konfigurieren Update-Verhalten um anzupassen, wie Updates angewendet werden
Mit der Azure-DevOps-Integration kannst du deine Capgo-Deployments automatisieren und so für konsistente, zuverlässige Updates bei den Nutzern deiner Mobile-App sorgen.
Weiter mit der Azure DevOps-Integration
Abschnitt mit dem Titel „Weiter mit der Azure-DevOps-Integration“Wenn du es nutzt Azure-DevOps-Integration um CI/CD-Automatisierung zu planen, verbinde es mit Capgo CI/CD für den Produkt-Workflow in Capgo CI/CD, Capgo Native Builds optimieren für den Produkt-Workflow in Capgo Native Builds, Capgo Integrationen für den Produkt-Workflow in Capgo Integrations, CI/CD-Integration für die Implementierungsdetails in der CI/CD-Integration und GitHub Actions-Integration für die Implementierungsdetails in der GitHub Actions-Integration.