VSTS缺少某些构建标志:env:BUILD_SOURCEVERSIONMESSAGE

时间:2017-08-24 03:56:47

标签: git powershell azure-devops azure-pipelines

在我的Visual Studio Team Services构建中,我从一个bitbucket repo中拉出来。我试图获取提交消息并在powershell脚本中使用它。

在我的powershell脚本中,我有以下代码。

 param (
    ##Expect to be passed parameter $(Build.SOURCEVERSIONMESSAGE)
    [string]$commitMessage = ""
 )

Write-Warning "Source Message: $commitMessage"
Write-Warning "SOURCEVERSIONMESSAGE: $env:Build_SOURCEVERSIONMESSAGE"
Get-ChildItem Env:

这给了我以下错误:

2017-08-24T02:18:27.0938681Z ##[command]. 'd:\a\1\s\Pcmtec.Azure\DeploymentScripts\SetBuildTagTest.ps1' -commitMessage $(Build.SOURCEVERSIONMESSAGE)

2017-08-24T02:18:30.3970727Z ##[error]Build.SOURCEVERSIONMESSAGE : The term 'Build.SOURCEVERSIONMESSAGE' is not recognized as the name of a cmdlet, 
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the 
path is correct and try again.

At line:1 char:82
+ ... pts\SetBuildTagTest.ps1' -commitMessage $(Build.SOURCEVERSIONMESSAGE)
+                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Build.SOURCEVERSIONMESSAGE:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


2017-08-24T02:18:30.4020718Z WARNING: Source Message: 
2017-08-24T02:18:30.4020718Z WARNING: SOURCEVERSIONMESSAGE: 

然后打印出所有env变量。我得到的只有:

BUILD_ARTIFACTSTAGINGDIRECTORY 
BUILD_BINARIESDIRECTORY        
BUILD_BUILDID                  
BUILD_BUILDNUMBER              
BUILD_BUILDURI                 
BUILD_CONTAINERID              
BUILD_DEFINITIONNAME           
BUILD_DEFINITIONVERSION        
BUILD_QUEUEDBY                 
BUILD_QUEUEDBYID               
BUILD_REASON                   
BUILD_REPOSITORY_CLEAN         
BUILD_REPOSITORY_GIT_SUBMOD... 
BUILD_REPOSITORY_ID            
BUILD_REPOSITORY_LOCALPATH     
BUILD_REPOSITORY_NAME          
BUILD_REPOSITORY_PROVIDER      
BUILD_REPOSITORY_URI           
BUILD_REQUESTEDFOR             
BUILD_REQUESTEDFOREMAIL        
BUILD_REQUESTEDFORID           
BUILD_SOURCEBRANCH             
BUILD_SOURCEBRANCHNAME         
BUILD_SOURCESDIRECTORY         
BUILD_SOURCEVERSION            
BUILD_STAGINGDIRECTORY         
BUILDCONFIGURATION   

为什么缺少BUILD_SOURCEVERSIONMESSAGE?

1 个答案:

答案 0 :(得分:1)

  

为什么缺少BUILD_SOURCEVERSIONMESSAGE?

我不知道,但之前报告失踪,as you noted(以及mentioned here as well)。

我仍然会使用Git命令替代git log --format='%s' -1:如果这里没有值,那至少会给出一个线索。