YAML pipeline templates

To make it more generic, you can use templates in your YAML pipeline. This means that you store the YAML file definitions for each task as separate files in a repository and you can refer to these templates from your YAML pipeline. The definitions are shared with all of the apps using them in their YAML pipeline, and if you need to fix something in the definition, you will fix it in one place. Of course, in this way, you can screw up all of your pipelines from one place. Be warned!

This is how you create the pipeline:

  1. Create a new repository for your templates.
  2. Put the YAML files with the definitions of the tasks into it:

  1. Add a reference to the repository to the YAML pipeline file:

The reference parameters are as follows:

    • Repository: The name as it is used in the YAML pipeline file
    • Type: The source repository type
    • Name: The repository name
    • Ref: The branch or a reference to the version of templates to be used
    • Endpoint: The name of the endpoint defined in the Azure DevOps Service connections section
  1. Add a service connection with the same name as your repository into Azure DevOps Service connections:

  1. Change the YAML file to reference these templates as the steps:

In the YAML file, we have these references:

  • Template: The path and name of the file in the @MSDYN365BC_Yaml repository
  • Parameters: The parameter values for the task

All repository-specific settings should stay in your YAML pipeline file. All shared things such as step definitions should be in the template repository.

You can find the example for the template and pipeline file at https://github.com/kine/MSDYN365BC_Yaml.

To swap a new app using this template, you can clone the app as a template at https://github.com/kine/MSDyn365BC_AppTemplate.

Just for future reference, as a generic YAML pipeline for Dynamics 365 Business Central, you can also refer to the following YAML definition:

variables:
build.clean: all
platform: x64

trigger: none

steps:
- task: PowerShell@2
displayName: 'Install NAVContainerHelper module'
inputs:
targetType: filePath
filePath: 'BuildScriptsInstallNAVContainerHelper.ps1'

- task: PowerShell@2
displayName: 'Create a Docker Container for the build'
inputs:
targetType: filePath
filePath: 'BuildScriptsCreateDockerContainer.ps1'
arguments: '-credential ([PSCredential]::new("$(DockerContainerUsername)", (ConvertTo-SecureString -String "$(DockerContainerPassword)" -AsPlainText -Force)))'

- task: PowerShell@2
displayName: 'Copy Files to Docker Container'
inputs:
targetType: filePath
filePath: 'BuildScriptsCopyFilesToDockerContainer.ps1'

- task: PowerShell@2
displayName: 'Compile extension stored in the repository'
inputs:
targetType: filePath
filePath: 'BuildScriptsCompileApp.ps1'
arguments: '-Credential ([PSCredential]::new("$(DockerContainerUsername)", (ConvertTo-SecureString -String "$(DockerContainerPassword)" -AsPlainText -Force))) -BuildFolder "$(Build.Repository.LocalPath)" -BuildArtifactFolder "$(Build.ArtifactStagingDirectory)"'
failOnStderr: true

- task: PowerShell@2
displayName: 'Publish extension'
inputs:
targetType: filePath
filePath: 'BuildScriptsPublishApp.ps1'
arguments: '-Credential ([PSCredential]::new("$(DockerContainerUsername)", (ConvertTo-SecureString -String "$(DockerContainerPassword)" -AsPlainText -Force))) -BuildArtifactFolder "$(Build.ArtifactStagingDirectory)"'
failOnStderr: true

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifacts'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: FinalApp

This pipeline model uses a set of PowerShell scripts that you can store in your repository  in a folder called BuildScripts. This can be stored together with your extension's files, as shown in the following screenshot:

If successfully executed, this pipeline publishes the final .app file for your Dynamics 365 Business Central extension as an Artifact (output of the pipeline), which you can download from the build summary page.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.29.145