How to do it...

  1. In your web browser, navigate to https://dev.azure.com and log in with your Azure DevOps account.
  2. Open the televisionShow project.
  3. On the left menu, select Pipelines | Releases.
  4. Click New pipeline.
  5. On the Select a template dialog, press Empty job:

  1. On the Stage dialog, set Stage name to Create testing environment. Click the X in the top-right corner of the Stage dialog to close it.
  2. Click Save in the top-right corner of the screen.
  3. Click OK.
  4. In the Artifacts box, click Add:

  1. In the Add an artifact screen, select Build, and set the following values:

This tells the release pipeline that we want to use the latest build from the televisionShow build pipeline as the artifact that we will deploy.

Make sure that the Source alias name matches the name of the artifact that you configure in the build pipeline, otherwise the release pipeline will not be able to get the artifact. In the event that your build pipeline produces multiple artifacts, make sure you use the correct one.
  1. Click Add.
  2. In the Artifacts box, click the Continuous deployment trigger () icon.
  3. Enable Continuous deployment trigger and select Add | The build pipeline's default branch:

  1. Click the X to close the Continuous deployment trigger screen.
  2. Click Save in the top-right corner of your screen.
  3. Click OK.
  4. At the top of your screen, select Tasks | Create testing environment.
  5. Select Agent job.
  6. On the right side, under Agent selection, set Agent pool to televisionShow-local:

  1. Click the + button next to Agent job:

  1. In the Add tasks screen, search for powershell and click the PowerShell button:

  1. Click Add.
  2. Click the PowerShell Script task on the left side.
  3. In the PowerShell screen on the right side, set the following field values:
    • Display name: Create container
    • Type: Inline
    • ErrorActionPreference: Stop
  4. Clear out the existing contents of the Script field, and then add the following code:
if (Test-NavContainer -containerName $(containerName))
{
Remove-NavContainer -containerName $(containerName)
}
New-NavContainer -containerName $(containerName) `
-accept_eula `
-accept_outdated `
-auth NavUserPassword `
-Credential (New-Object pscredential $(containerUserName),
(ConvertTo-SecureString -String $(containerPassword) -AsPlainText
-Force)) `
-doNotExportObjectsToText `
-imageName $(imageName) `
-alwaysPull `
-shortcuts CommonStartMenu `
-restart always `
-updateHosts `
-useBestContainerOS `
-assignPremiumPlan `
-additionalParameters @("--volume
""$($env:Agent_HomeDirectory):C:Agent""")

This code will check to see whether the deployment container exists, and if it does, it will remove it. After that, it will create a new deployment container.

  1. Click the + button next to Agent job.
  2. In the Add tasks screen, search for powershell and click the PowerShell button.
  3. Click Add.
  4. Click the PowerShell Script task on the left side.
  5. In the PowerShell screen on the right side, set the following field values:
    • Display name: Install BC Application
    • Type: Inline
    • ErrorActionPreference: Stop
  6. Now, add some code to install our Business Central application into the container. Clear out the existing contents of the Script field, and then add the following code:
Get-ChildItem -Path (Join-Path -Path $env:System_ArtifactsDirectory -ChildPath ($env:Release_PrimaryArtifactSourceAlias + '	elevisionShowApp')) -Filter '*.app' | ForEach-Object {
Publish-NavContainerApp -containerName $env:containerName
-appFile $_.FullName -skipVerification -sync -install
}

The preceding code looks in the folder where the pipeline downloaded the artifact to. For each Business Central application in that folder (in our case, it's just one), it will install it into the container that was created earlier in the process.

  1. At the top of the screen, click Variables.
  2. Select Pipeline variables.
  3. Click Add.
  4. Enter the following values:
    • Name: containerName
    • Value: release
  5. Continue to click Add and create the following variables:
Name Value
containerUserName admin
containerPassword Pass@word1
imageName
mcr.microsoft.com/businesscentral/sandbox:us
  1. Click Save in the top-right corner of your screen.
  2. Click OK.
  3. Now, let's run our release pipeline to make sure that it works. In the top-right corner of your screen, click Create release.
  4. On the Create a new release screen, click the  button and select Create testing environment:

  1. At the bottom right of the screen, click Create.
  2. In the top-right corner of your screen, click View releases.
If you don't see the View releases button, then check the top-right corner under the ... button!
  1. Here, you can see the release that you created. Click on the release name (for example, Release-1) to open it:

  1. Hover your mouse over the Create testing environment stage, and then click Deploy:

  1. On the Create testing environment screen, click Deploy.
Make sure to check out the other information on this screen, as follows:

Commits: Shows you the source code changes that will be included in the release
Work Items: Shows you the associated work items for the release
Artifacts: Shows you what version of the artifact(s) your release will include
  1. While the release pipeline is being executed, hover over the Create testing environment stage and click the Logs button:

You can view the logs of a specific step in the pipeline by clicking on it:

When the release pipeline has completed, the status should look like this:

It may take 10 – 20 minutes to execute the release pipeline the first time, depending on the speed of the machine that is executing it. This is because the Docker image needs to be downloaded. Unless the image is updated and needs to be downloaded again, subsequent runs of the pipeline will be shorter.
  1. Now, you can log in to the container that the release pipeline created:
    1. Log in to the machine that you installed the pipeline agent on.
    2. Using a web browser, navigate to the Business Central system (for example, http://release/NAV).
    3. Search for Television and you should see results for things such as Television Show List and Episodes.
If you are not sure what the URL is for the Business Central system, then look in the logs of the release pipeline and click on the setup container step. Look for the Web Client value near the end of the log.
..................Content has been hidden....................

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