< Back

Get-BuildVariable

Sun Jan 12, 2020 6:41 pm

NAME Get-BuildVariable



SYNOPSIS

Normalize build system variables





SYNTAX

Get-BuildVariable [[-Path] <Object>] [[-GitPath] <Object>] [<CommonParameters>]





DESCRIPTION

Normalize build system variables



Each build system exposes common variables it's own unique way, if at all.

This function was written to enable more portable builds, and

to avoid tightly coupling your build scripts with your build system



Gathers from:

AppVeyor

GitLab CI

Jenkins

Teamcity

Azure Pipelines

Bamboo

GoCD

Travis CI

GitHub Actions



For Teamcity the VCS Checkout Mode needs to be to checkout files on agent.

Since TeamCity 10.0, this is the default setting for the newly created build configurations.



Git needs to be available on the agent for this.



Produces:

BuildSystem: Build system we're running under

ProjectPath: Project root for cloned repo

BranchName: git branch for this build

CommitMessage: git commit message for this build

BuildNumber: Build number provided by the CI system





PARAMETERS

-Path <Object>

Path to project root. Defaults to the current working path



Required? false

Position? 1

Default value $PWD.Path

Accept pipeline input? false

Accept wildcard characters? false



-GitPath <Object>

Path to git. Defaults to git (i.e. git is in $ENV:PATH)



Required? false

Position? 2

Default value git

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





We assume you are in the project root, for several of the fallback options



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-BuildVariable















RELATED LINKS

https://github.com/RamblingCookieMonster/BuildHelpers

Get-ProjectName

Set-BuildEnvironment

about_BuildHelpers