本文介绍了VSTS缺少某些构建标志:env:BUILD_SOURCEVERSIONMESSAGE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Visual Studio Team Services构建中,我从一个bitbucket回购协议中提取。我试图获取提交信息并将其用于PowerShell脚本中。



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

  param(
##期望传递参数$(Build.SOURCEVERSIONMESSAGE)
[string] $ commitMessage =


写入警告源消息:$ commitMessage
写入警告SOURCEVERSIONMESSAGE:$ env:Build_SOURCEVERSIONMESSAGE
Get-ChildItem Env:
  2017-08-24T02:18:27.0938681Z ## [command]。 'd:\\\\\\\\\\\\\\\\\\\\''' 30.3970727Z ## [error] Build.SOURCEVERSIONMESSAGE:术语'Build.SOURCEVERSIONMESSAGE'不被识别为cmdlet,
函数,脚本文件或可操作程序的名称。检查名称的拼写,或者如果包含路径,请验证
路径是否正确,然后重试。

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


2017-08-24T02:18:30.4020718Z警告:消息来源:
2017-08-24T02:18:30.4020718Z警告:SOURCEVERSIONMESSAGE:

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

$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ BUILD_ARTIFACTSTAGINGDIRECTORY
BUILD_BINARIESDIRECTORY
BUILD_BUILDID
BUILD_BUILDNUMBER
BUILD_BUILDURI
BUILD_CONTAINERID
BUILD_DEFINITIONNAME
UILD_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
UILD_REQUESTEDFOR
BUILD_REQUESTEDFOREMAIL
BUILD_REQUESTEDFORID
BUILD_SOURCEBRANCH
BUILD_SOURCEBRANCHNAME
BUILD_SOURCESDIRECTORY
BUILD_SOURCEVERSION
BUILD_STAGINGDIRECTORY
BUILDCONFIGURATION

为什么BUILD_SOURCEVERSIONMESSAGE缺失?


I 不知道,但之前报告缺少,(以及)。

我仍然会使用Git命令替代 git log --format ='%s' - 1 :如果这里没有任何值,那至少可以提供线索。


In my Visual Studio Team Services build I am pulling from a bitbucket repo. I am trying to get the commit message and use it in a powershell script.

In my powershell script I have the following code.

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

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

Which gives me the following error:

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: 

It then prints out all the env variables. The only ones I get are:

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   

Why is BUILD_SOURCEVERSIONMESSAGE missing?

解决方案

I don't know, but it was reported missing before, as you noted (and in mentioned here as well).

I would still use the Git command alternative git log --format='%s' -1: if there is no value here either, that would at least give a clue.

这篇关于VSTS缺少某些构建标志:env:BUILD_SOURCEVERSIONMESSAGE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 11:44