Reliability

Your build process does not only need to be traceable but also very reliable. By using proper error handling in PowerShell, Desired State Configuration, and Just Enough Administration, you can also improve the reliability of your process.

Usually during a build, virtual machines in a service are created and software is deployed to them. With DSC, this gets very easy. By using the same configuration with different configuration data depending on the environment (Dev, QA, Prod) or on the service that is deployed, you only have a very minimal amount of work to prepare the necessary infrastructure for release.

Just Enough Administration can help improve reliability and trust in the pipeline as well, by deploying restricted endpoints for your build so that only the use of a restricted set of cmdlets is allowed.

For a great paper on building trust in the release pipeline, see Matt Hitchcock's GitHub paper: https://github.com/matthitchcock/trust-the-rp/blob/master/trust-the-release-pipeline.md.

With additional modules, such as PSDepend, you can easily install dependencies from different sources. Handling dependencies is an important job for developers during a build, especially when it comes to external libraries that cannot be controlled by the developer. PSDepend can download from NuGet galleries such as the PowerShell gallery, NuGet.org (https://www.nuget.org/), or Chocolatey so that even binary files can easily be provided during build in specific versions:

# Easy dependency handling
Get-Command -Module PSDepend

# A hashtable of dependencies, see https://github.com/RamblingCookieMonster/PSDepend for details
@'
@{
psdeploy = 'latest'

buildhelpers_0_0_20 = @{
Name = 'buildhelpers'
DependencyType = 'PSGalleryModule'
Parameters = @{
Repository = 'PSGallery'
SkipPublisherCheck = $true
}
Version = '0.0.20'
DependsOn = 'nuget'
}

notepadplusplus = @{
DependencyType = 'Package'
Target = 'C: pp'
DependsOn = 'nuget'
}

nuget = @{
DependencyType = 'FileDownload'
Source = 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe'
Target = 'C: uget.exe'
}
}
'@ | Out-File -FilePath .Dependencies.psd1

# Import dependencies
$dependencies = Get-Dependency -Path .Dependencies.psd1

# Try to install all dependencies
Install-Dependency -Dependency $dependencies

At the moment, PSDepend supports the following external dependencies:

  • Command: Arbitrary script blocks
  • FileDownload: Download files from anywhere
  • FileSystem: File copies
  • Git: Check out (a branch of) a git repository
  • GitHub: Install a module from a GitHub repository
  • Npm: Download Node.js packages
  • PSGalleryModule: Download modules from PowerShell gallery
  • PSGalleryNuget: Use nuget.exe to download from a NuGet feed (not limited to PSGallery)
  • Package: Use PackageManagement to install anything from a module to binary files

Properly managing dependencies are a crucial part of your build process. Libraries and other dependencies need to exist at build time in the correct version to get your deployment going:

Cloud providers such as Azure, AWS, and Google usually version their APIs to help you with versioning when deploying workloads in the cloud.

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

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