Menu Close

How to create a Bamboo build plan to build and deploy a Nuget package

Task 1 – Source Code Checkout

Checkout Default Repository

Task 2 – Command

Restore Nuget Packages

Task 3 – Set Bamboo Variables

Import version dependent build variables from a file.
Or, set variables in the build plan configuration, or set variables from Jira release process.
Version variables are simply made up by whoever sets up the build plan. There are no particular
version variables. So, create a variable and give it a name such as ‘version’.

Bamboo variables.txt


Example Powershell Script

You need to import your version variable into your Powershell script.

IMPORTANT, Inline and external Powershell scripts have direct access to the bamboo variables.

Inline scripts access bamboo variables like this:


External scripts access bamboo variables like this:



-outputPath "Shared\VersionInfo.cs" -versionNumber ${bamboo.expro.version} -buildNumber ${bamboo.buildNumber}

Script file:

param (
    [string] $outputPath = $(throw "-outputPath is required."),
    [string] $buildNumber = $(throw "-buildNumber is required."),
    [string] $versionNumber = $(throw "-versionNumber is required.")
    # Fetch the date parameters that will be encoded into the version
    $year = Get-Date -UFormat "%y"
    $dayOfYear = (Get-Date).DayOfYear
    # assemble the version number
    # Git does not provide a revision number, so the revision is omitted
    $finalVersion = "$versionNumber.$buildNumber.$year$dayOfYear"
    "Version Number: $finalVersion"
    "Writing version to '$outputPath'"   
    # write to file
    "// <copyright file=""VersionInfo.cs"" company=""Expro North Sea Ltd"">" | Out-File $outputPath
    "// Copyright (c) 2017 Expro North Sea Ltd. All rights reserved." | Out-File $outputPath -Append
    "// </copyright>" | Out-File $outputPath -Append
    "using System.Reflection;" | Out-File $outputPath -Append
    "[assembly: AssemblyVersion(`"$finalVersion`")]" | Out-File $outputPath -Append
    # spit out the exception that has been caught so that the bamboo log traps it.
    Write-Error $_.Exception.Message
    # return an error code to bamboo
    exit -1

Task 5 – Command

Compile to Nuget Package


pack ExproWWS.Common.csproj -Build -Properties Configuration=Release