Prepping the Build Pipeline

Azure Pipelines is a cloud service that you can use to automatically build and test your code project and make it available to other users. It works with about any language or project type.

This blog is part of a series of blog about “Creating PowerShell modules with Azure Devops.

Azure Pipelines combines continuous integration (CI) and continuous delivery (CD) to test and build your code and ship it to any target constantly and consistently

Before you can start using the Build pipelines, we need to prep the environment. These preparations are necessary for the build process to work correct. During the build process the build pipeline looks for a Variable group and in the Variable group the location of the feeds are describe. This feed is used for all modules that are created within the project.

[!TIP]
If you want to use specific feeds for specific modulus you can change the location of the variable to the build pipeline. The pipeline variables overrule the general variables.

We need to do the following steps:

  • Create an Artifacts Feed
  • Create a Library item
  • Variables

Create a Artifacts Feed

For more information:  Creating a feed

Create a Library item

  • Log in the Azure DevOps environment. (https://dev.azure.com/)
  • Select the project you are working on.
  • Select “Pipelines
  • Select “Library
  • Select “+ Variable group
  • Change the Variable group name to General-build-variable
  • Select + Add
  • Add the required Variables

Variables

The following variable need to be used with the General-build-variable build pipeline.

NameValue
module.acceptableCodeCoveragePercent75
FailTaskIfNoControlsScannedTrue/False
module.FeedName
module.SourceLocation

module.acceptableCodeCoveragePercent

During the test phase within the build process the code coverage is tested. This test tested the lines that are being tested and generate a percentage from it. When the score is below this value the release will be canceled and you need to increase the number of lines that are being tested.

FailTaskIfNoControlsScanned

This variable is to control the behavior of the SVT extension in case of no controls scanned. For e.g., using this, one may choose to pass the task if it is configured to scan only ‘High’ severity control but there are no resources for which ‘High’ severity controls are applicable. Secure DevOps Kit for Azure (AzSK)

Retrieving Feedname and Source Location

The following two variable you need to construct yourself. The easiest way to do this is:

  • Select “Artifacts
  • Select “Connect to feed
  • Select “NuGet.exe

[!WARNING]
Because we are using the command “Register-PackageSource” only V2 source locations are allowed.

So we need to recreate the source location from:
https://pkgs.dev.azure.com/TheAzCloudNinja/_packaging/Test/nuget/v3/index.json
to:
https://pkgs.dev.azure.com/TheAzCloudNinja/_packaging/Test/nuget/v2/

module.FeedName

Because the build pipeline will publish it content into an Artifact it needs to have the name of this feed. The process of creating a feed is documented here: Creating a feed

module.SourceLocation

The module.SourceLocation is the location of where the packages need to be published to.

The feed as a PSRepository you will need a name, source location, and publish location. The name is what you will call the PSRepository and can be anything you chose in this example we call it “myAzArtifactsRepo”. Your source location and publish location will be the same uri and will be the format: “https://pkgs.dev.azure.com/’yourorganizationname’/_packaging/’yourfeedname’/nuget/v2/“.

[!WARNING]
Because we are using the command “Register-PackageSource” only V2 source locations are allowed.

Leave a Reply

Your email address will not be published. Required fields are marked *