Skip to content

Instantly share code, notes, and snippets.

@paulbreuler
Last active October 30, 2019 20:36
Show Gist options
  • Save paulbreuler/ffb74363d9e2479b5d91aa7363735714 to your computer and use it in GitHub Desktop.
Save paulbreuler/ffb74363d9e2479b5d91aa7363735714 to your computer and use it in GitHub Desktop.
PowerApps Build Tools YAML based build and release for Azure Pipelines using an intermediate build environment

Description:

This simple multi-stage YAML pipeline packs a PowerApps model-driven app (Dynamics 365 CRM/CE) solution from source control (Assumes an unmanaged solution has been unpacked using SolutionPackager and stored in source) and runs it through an intermediate build environment to create a managed solution artifact. The output artifact is then run through a deployment job with an Azure Pipeline Environment specified that allows us to track deployments to the specified target environment.

Reference the PowerApp Build Tools Lab for directions on setting the pipeline up using the classic editor. The YAML in this gist follows the same steps as the classic editor setup used in the labs but adds more variables to the mix.

Check out the D365 CE Pipelines repo for templated pipeline examples.

Required Variables:

SolutionContentDirectory - The path to your solution contents directory e.g. unpacked-solutions/myApp/.

SolutionName - The desired output name of your solution e.g myApp.

BuildEnvironment - The service connection name reference for the environment that will be used in the process of creating a managed solution.

TargetEnvironment - The service connection name reference for the environment that we want our managed solution artifact to be deployed to.

References:

name: $(Build.DefinitionName)-$(Build.SourceBranch)-$(Date:yyyyMMdd)
trigger:
- master
stages:
- stage: Build
jobs:
- job:
displayName: "Build managed solution"
pool:
vmImage: 'vs2017-win2016'
steps:
- task: PowerAppsToolInstaller@0
- task: PowerAppsPackSolution@0
inputs:
SolutionSourceFolder: '$(Build.SourcesDirectory)\$(SolutionContentDirectory)'
SolutionOutputFile: '$(Pipeline.Workspace)\unmanaged-solutions\$(SolutionName).zip'
SolutionType: Unmanaged
### Region: Import into an intermediate envrionment to generate managed solution ###
- task: PowerAppsImportSolution@0
inputs:
PowerAppsEnvironment: '$(BuildEnvironment)'
SolutionInputFile: '$(Pipeline.Workspace)\unmanaged-solutions\$(SolutionName).zip'
AsyncOperation: true
MaxAsyncWaitTime: '240'
- task: PowerAppsExportSolution@0
inputs:
PowerAppsEnvironment: $(BuildEnvironment)
SolutionName: '$(SolutionName)'
SolutionOutputFile: '$(Pipeline.Workspace)\managed-solutions\$(SolutionName)_managed.zip'
Managed: true
ExportAutoNumberingSettings: false
ExportCalendarSettings: false
ExportCustomizationSettings: false
ExportEmailTrackingSettings: false
ExportGeneralSettings: false
ExportIsvConfig: false
ExportMarketingSettings: false
ExportOutlookSynchronizationSettings: false
ExportRelationshipRoles: false
ExportSales: false
displayName: 'PowerApps Export Solution - $(SolutionName)_managed.zip'
### end region ###
- publish: $(Pipeline.Workspace)\managed-solutions
artifact: solution-artifacts
displayName: Publish pipeline artifact - $(SolutionName)_managed.zip
- stage: Release
jobs:
# track deployments on the environment
- deployment: Release
displayName: Release managed solution to $(TargetEnvironment)
pool:
vmImage: 'vs2017-win2016'
# Automatically creates an environment in Azure DevOps with the name of the target environment
# Allows tracking of deployments to that environment and enabling checks to gate deployments
environment: $(TargetEnvironment)
strategy:
runOnce:
deploy:
steps:
# Artifact download happens automatically in a deployment job
- task: PowerAppsToolInstaller@0
- task: PowerAppsImportSolution@0
inputs:
PowerAppsEnvironment: '$(TargetEnvironment)'
SolutionInputFile: '$(Pipeline.Workspace)\solution-artifacts\$(SolutionName)_managed.zip'
AsyncOperation: true
MaxAsyncWaitTime: '240'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment