Sélectionner une page

How‑to : Pipeline de release (multi‑stages) et smoke tests

Nous promouvons l’artefact buildé en TEST puis PROD, avec approbations et tests de fumée automatisés.

release.yml

Le YAML ci‑dessous orchestre import managed et vérifications.

trigger: none

stages:
- stage: TEST
  displayName: Deploy to TEST
  variables:
    - group: pp-customapi-test
  jobs:
  - job: import
    pool: { vmImage: 'windows-latest' }
    steps:
    - download: current
      artifact: drop
    - powershell: |
        pac auth create --url $(ENV_URL) --tenant $(TENANT_ID) --applicationId $(APP_ID_TEST) --clientSecret $(APP_SECRET_TEST) --name TestAuth
        pac solution import --path $(Pipeline.Workspace)/drop/Marlk_SalesCore.zip --async --publish-changes true --force-overwrite true
      displayName: Import managed (TEST)
    - powershell: |
        ./ops/scripts/smoke-test-api.ps1 -EnvUrl $(ENV_URL) -TenantId $(TENANT_ID) -AppId $(APP_ID_TEST) -AppSecret $(APP_SECRET_TEST)
      displayName: Smoke tests

- stage: PROD
  displayName: Deploy to PROD
  dependsOn: TEST
  variables:
    - group: pp-customapi-prod
  approval: Manual
  jobs:
  - job: import
    pool: { vmImage: 'windows-latest' }
    steps:
    - download: current
      artifact: drop
    - powershell: |
        pac auth create --url $(ENV_URL) --tenant $(TENANT_ID) --applicationId $(APP_ID_PROD) --clientSecret $(APP_SECRET_PROD) --name ProdAuth
        pac solution import --path $(Pipeline.Workspace)/drop/Marlk_SalesCore.zip --async --publish-changes true --force-overwrite true
      displayName: Import managed (PROD)
    - powershell: |
        ./ops/scripts/smoke-test-api.ps1 -EnvUrl $(ENV_URL) -TenantId $(TENANT_ID) -AppId $(APP_ID_PROD) -AppSecret $(APP_SECRET_PROD)
      displayName: Smoke tests

Script PowerShell : smoke-test-api.ps1

Nous appelons l’API et validons une réponse saine.

param(
  [Parameter(Mandatory)] [string]$EnvUrl,
  [Parameter(Mandatory)] [string]$TenantId,
  [Parameter(Mandatory)] [string]$AppId,
  [Parameter(Mandatory)] [string]$AppSecret
)
$body = @{ opportunityid = [guid]::Empty; applydiscount = $false } | ConvertTo-Json
$token = (az account get-access-token --resource $EnvUrl --tenant $TenantId --client-id $AppId --client-secret $AppSecret | ConvertFrom-Json).accessToken
$resp = Invoke-RestMethod -Uri "$EnvUrl/api/data/v9.2/mar_custom_CalculateOpportunityMargin" -Method Post -Headers @{ Authorization = "Bearer $token"; 'Content-Type' = 'application/json' } -Body $body
if (-not $resp.marginrate -and -not $resp.marginamount) { throw 'Smoke test failed' }
Write-Host 'Smoke OK'

Approvals et evidence

Nous journalisons le go/no‑go de manière vérifiable.

  • Approbation manuelle avant PROD.
  • Conservation des logs smoke test en artefacts.
  • Change log généré depuis commits.