我正在尝试使用自定义条件为发布定义设置逻辑 例如。如果条件等于某些数据,则执行此步骤,否则跳过该步骤 条件是:
eq(variables['Release.Artifacts._XXXXX_.BuildNumber'], 'YYY')
此处_XXXXX_
是来源别名,YYY
是内部版本号
另外,我尝试了以下内容:
eq(variables['Build.BuildNumber'], 'YYY')
在构建期间使用构建定义中的以下操作设置构建号:( PowerShell脚本)
Write-Host ("##vso[build.updatebuildnumber]YYY")
然而,释放运行无论如何都会跳过此步骤 检查日志时,我清楚地看到构建号等于我的(必需)数据:
[BUILD_BUILDID] --> [135]
[BUILD_BUILDNUMBER] --> [YYY]
[BUILD_BUILDURI] --> [vstfs:///Build/Build/135]
[BUILD_DEFINITIONID] --> [8]
[BUILD_DEFINITIONNAME] --> [XXXXX]
[BUILD_PROJECTID] --> [1591217f-c442-4ac1-8afd-072c15f20d59]
[BUILD_PROJECTNAME] --> [XXX Application]
[BUILD_REPOSITORY_ID] --> [1591217f-c442-4ac1-8afd-072c15f20d59]
[BUILD_REPOSITORY_NAME] --> [XXX Application]
[BUILD_REPOSITORY_PROVIDER] --> [TfsVersionControl]
[BUILD_REQUESTEDFOR] --> [Sergey]
[BUILD_REQUESTEDFORID] --> [6935e75f-f1d3-434d-9665-536155f280e1]
[BUILD_SOURCEBRANCH] --> [$/XXX Application/ZZZZ_699]
[BUILD_SOURCEBRANCHNAME] --> [ZZZZ_699]
[BUILD_SOURCEVERSION] --> [922]
[BUILD_TYPE] --> [Build]
[KEYVAULTNAME] --> [XXXkeyvault]
[KEYVAULTSECRETNAME] --> [sqlAdminPassword]
[MSDEPLOY_HTTP_USER_AGENT] --> [VSTS_e9a6b698-6440-443e-a398-c358fe7b1c29_release_15_264_1546_1]
[RELEASE_ARTIFACTS__XXXXX_BUILDID] --> [135]
[RELEASE_ARTIFACTS__XXXXX_BUILDNUMBER] --> [YYY]
[RELEASE_ARTIFACTS__XXXXX_BUILDURI] --> [vstfs:///Build/Build/135]
[RELEASE_ARTIFACTS__XXXXX_DEFINITIONID] --> [8]
[RELEASE_ARTIFACTS__XXXXX_DEFINITIONNAME] --> [XXXXX]
[RELEASE_ARTIFACTS__XXXXX_PROJECTID] --> [1591217f-c442-4ac1-8afd-072c15f20d59]
[RELEASE_ARTIFACTS__XXXXX_PROJECTNAME] --> [XXX Application]
[RELEASE_ARTIFACTS__XXXXX_REPOSITORY_ID] --> [1591217f-c442-4ac1-8afd-072c15f20d59]
[RELEASE_ARTIFACTS__XXXXX_REPOSITORY_NAME] --> [XXX Application]
[RELEASE_ARTIFACTS__XXXXX_REPOSITORY_PROVIDER] --> [TfsVersionControl]
[RELEASE_ARTIFACTS__XXXXX_REQUESTEDFOR] --> [Sergey]
[RELEASE_ARTIFACTS__XXXXX_REQUESTEDFORID] --> [6935e75f-f1d3-434d-9665-536155f280e1]
[RELEASE_ARTIFACTS__XXXXX_SOURCEBRANCH] --> [$/XXX Application/ZZZZ_699]
[RELEASE_ARTIFACTS__XXXXX_SOURCEBRANCHNAME] --> [ZZZZ_699]
[RELEASE_ARTIFACTS__XXXXX_SOURCEVERSION] --> [922]
[RELEASE_ARTIFACTS__XXXXX_TYPE] --> [Build]
但是日志显示跳过了步骤(条件)评估:
2018-05-26T10:25:26.7133654Z ##[debug]Evaluating condition for step: 'Execute Azure SQL : DacpacTask'
2018-05-26T10:25:26.7145496Z ##[debug]Evaluating: eq(variables['Release.Artifacts._XXXXX_.BuildNumber'], 'YYY')
2018-05-26T10:25:26.7145830Z ##[debug]Evaluating eq:
2018-05-26T10:25:26.7151621Z ##[debug]..Evaluating indexer:
2018-05-26T10:25:26.7200306Z ##[debug]....Evaluating variables:
2018-05-26T10:25:26.7204538Z ##[debug]....=> Object
2018-05-26T10:25:26.7204829Z ##[debug]....Evaluating String:
2018-05-26T10:25:26.7205923Z ##[debug]....=> 'Release.Artifacts._XXXXX_.BuildNumber'
2018-05-26T10:25:26.7223045Z ##[debug]..=> Null
2018-05-26T10:25:26.7223345Z ##[debug]..Evaluating String:
2018-05-26T10:25:26.7223658Z ##[debug]..=> 'YYY'
2018-05-26T10:25:26.7239489Z ##[debug]..=> Unable to coerce String to Null.
2018-05-26T10:25:26.7239951Z ##[debug]=> False
2018-05-26T10:25:26.7244414Z ##[debug]Expanded: eq(Null, 'YYY')
2018-05-26T10:25:26.7244768Z ##[debug]Result: False
我遇到了强制错误 - 看起来Release.Artifacts._XXXXX_.BuildNumber
变量未被评估或不存在。
答案 0 :(得分:0)
新版本定义(从头开始)完美运行
Release.Artifacts.{source_alias}.BuildNumber
和Build.BuildNumber
都可用。
似乎前一个是heisenbug或类似的东西。