2017-08-24 2 views
1

Dans mon build Visual Studio Team Services je tire d'un repo bitbucket. J'essaie d'obtenir le message de validation et de l'utiliser dans un script PowerShell.VSTS manquant certain drapeau de construction: env: BUILD_SOURCEVERSIONMESSAGE

Dans mon script PowerShell j'ai le code suivant.

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

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

Ce qui me donne l'erreur suivante:

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: 

Il imprime ensuite toutes les variables env. Les seuls que j'obtiens sont:

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 

Pourquoi BUILD_SOURCEVERSIONMESSAGE est manquant?

Répondre

1

Why is BUILD_SOURCEVERSIONMESSAGE missing?

Je ne sais pas, mais il a été porté disparu avant, as you noted (et mentioned here as well).

J'utiliserais toujours la commande Git alternative git log --format='%s' -1: s'il n'y a pas de valeur non plus, cela donnerait au moins un indice.

+0

"git log head -1" a fait l'affaire. Je vous remercie. – rolls