From 811fef595aa549c030fd923854c3732020781c7b Mon Sep 17 00:00:00 2001 From: Raimund Andree Date: Tue, 17 Sep 2019 02:23:37 +0530 Subject: [PATCH 1/2] Removing 'path' parameter from 'git log' command --- BuildHelpers/Public/Get-BuildVariable.ps1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/BuildHelpers/Public/Get-BuildVariable.ps1 b/BuildHelpers/Public/Get-BuildVariable.ps1 index 2bf79a6..5fe18cf 100644 --- a/BuildHelpers/Public/Get-BuildVariable.ps1 +++ b/BuildHelpers/Public/Get-BuildVariable.ps1 @@ -160,21 +160,21 @@ function Get-BuildVariable { 'CI_COMMIT_SHA' { if($WeCanGit) { - Invoke-Git @IGParams -Arguments "log --format=%B -n 1 $( (Get-Item -Path "ENV:$_").Value )" + Invoke-Git @IGParams -Arguments "log --format=%B -n 1" break } # Gitlab 9.0+ - thanks to mipadi http://stackoverflow.com/a/3357357/3067642 } 'CI_BUILD_REF' { if($WeCanGit) { - Invoke-Git @IGParams -Arguments "log --format=%B -n 1 $( (Get-Item -Path "ENV:$_").Value )" + Invoke-Git @IGParams -Arguments "log --format=%B -n 1" break } # Gitlab 8.x - thanks to mipadi http://stackoverflow.com/a/3357357/3067642 } 'GIT_COMMIT' { if($WeCanGit) { - Invoke-Git @IGParams -Arguments "log --format=%B -n 1 $( (Get-Item -Path "ENV:$_").Value )" + Invoke-Git @IGParams -Arguments "log --format=%B -n 1" break } # Jenkins - thanks to mipadi http://stackoverflow.com/a/3357357/3067642 } @@ -186,21 +186,21 @@ function Get-BuildVariable { 'SYSTEM_DEFAULTWORKINGDIRECTORY' { #Azure Pipelines, this will be triggered in the case of a classic release pipeline if($WeCanGit) { - (Invoke-Git @IGParams -Arguments "log --format=%B -n 1 $( (Get-Item -Path "ENV:$_").Value )").split([Environment]::NewLine,[System.StringSplitOptions]::RemoveEmptyEntries) -join " " + (Invoke-Git @IGParams -Arguments "log --format=%B -n 1").split([Environment]::NewLine,[System.StringSplitOptions]::RemoveEmptyEntries) -join " " break } # Azure Pipelines Classic Release (https://docs.microsoft.com/en-us/azure/devops/pipelines/release/variables) } 'BUILD_VCS_NUMBER' { if($WeCanGit) { - Invoke-Git @IGParams -Arguments "log --format=%B -n 1 $( (Get-Item -Path "ENV:$_").Value )" + Invoke-Git @IGParams -Arguments "log --format=%B -n 1" break } # Teamcity https://confluence.jetbrains.com/display/TCD10/Predefined+Build+Parameters } 'BAMBOO_REPOSITORY_REVISION_NUMBER' { if($WeCanGit) { - Invoke-Git @IGParams -Arguments "log --format=%B -n 1 $( (Get-Item -Path "ENV:$_").Value )" + Invoke-Git @IGParams -Arguments "log --format=%B -n 1" break } # Bamboo https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html } @@ -211,7 +211,7 @@ function Get-BuildVariable { 'GITHUB_SHA' { if($WeCanGit) { - Invoke-Git @IGParams -Arguments "log --format=%B -n 1 $( (Get-Item -Path "ENV:$_").Value )" + Invoke-Git @IGParams -Arguments "log --format=%B -n 1" break } # GitHub Actions https://developer.github.com/actions/creating-github-actions/accessing-the-runtime-environment/#environment-variables } From abe03e943366d4722434c18a2b6d4981550ee099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimund=20And=C3=A9e=20=5BMSFT=5D?= Date: Wed, 18 Sep 2019 08:26:52 +0530 Subject: [PATCH 2/2] Adding usage of variables again but chenged 'SYSTEM_DEFAULTWORKINGDIRECTORY' to 'BUILD_SOURCEVERSION' --- BuildHelpers/Public/Get-BuildVariable.ps1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/BuildHelpers/Public/Get-BuildVariable.ps1 b/BuildHelpers/Public/Get-BuildVariable.ps1 index 5fe18cf..25b6755 100644 --- a/BuildHelpers/Public/Get-BuildVariable.ps1 +++ b/BuildHelpers/Public/Get-BuildVariable.ps1 @@ -160,21 +160,21 @@ function Get-BuildVariable { 'CI_COMMIT_SHA' { if($WeCanGit) { - Invoke-Git @IGParams -Arguments "log --format=%B -n 1" + Invoke-Git @IGParams -Arguments "log --format=%B -n 1 $( (Get-Item -Path "ENV:$_").Value )" break } # Gitlab 9.0+ - thanks to mipadi http://stackoverflow.com/a/3357357/3067642 } 'CI_BUILD_REF' { if($WeCanGit) { - Invoke-Git @IGParams -Arguments "log --format=%B -n 1" + Invoke-Git @IGParams -Arguments "log --format=%B -n 1 $( (Get-Item -Path "ENV:$_").Value )" break } # Gitlab 8.x - thanks to mipadi http://stackoverflow.com/a/3357357/3067642 } 'GIT_COMMIT' { if($WeCanGit) { - Invoke-Git @IGParams -Arguments "log --format=%B -n 1" + Invoke-Git @IGParams -Arguments "log --format=%B -n 1 $( (Get-Item -Path "ENV:$_").Value )" break } # Jenkins - thanks to mipadi http://stackoverflow.com/a/3357357/3067642 } @@ -183,24 +183,24 @@ function Get-BuildVariable { break # Azure Pipelines Classic Build & YAML(https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables) } - 'SYSTEM_DEFAULTWORKINGDIRECTORY' { #Azure Pipelines, this will be triggered in the case of a classic release pipeline + 'BUILD_SOURCEVERSION' { #Azure Pipelines, this will be triggered in the case of a classic release pipeline if($WeCanGit) { - (Invoke-Git @IGParams -Arguments "log --format=%B -n 1").split([Environment]::NewLine,[System.StringSplitOptions]::RemoveEmptyEntries) -join " " + Invoke-Git @IGParams -Arguments "log --format=%B -n 1 $( (Get-Item -Path "ENV:$_").Value )" break } # Azure Pipelines Classic Release (https://docs.microsoft.com/en-us/azure/devops/pipelines/release/variables) } 'BUILD_VCS_NUMBER' { if($WeCanGit) { - Invoke-Git @IGParams -Arguments "log --format=%B -n 1" + Invoke-Git @IGParams -Arguments "log --format=%B -n 1 $( (Get-Item -Path "ENV:$_").Value )" break } # Teamcity https://confluence.jetbrains.com/display/TCD10/Predefined+Build+Parameters } 'BAMBOO_REPOSITORY_REVISION_NUMBER' { if($WeCanGit) { - Invoke-Git @IGParams -Arguments "log --format=%B -n 1" + Invoke-Git @IGParams -Arguments "log --format=%B -n 1 $( (Get-Item -Path "ENV:$_").Value )" break } # Bamboo https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html } @@ -211,7 +211,7 @@ function Get-BuildVariable { 'GITHUB_SHA' { if($WeCanGit) { - Invoke-Git @IGParams -Arguments "log --format=%B -n 1" + Invoke-Git @IGParams -Arguments "log --format=%B -n 1 $( (Get-Item -Path "ENV:$_").Value )" break } # GitHub Actions https://developer.github.com/actions/creating-github-actions/accessing-the-runtime-environment/#environment-variables }