问题描述
我有一个创建 html 文件的 powershell 脚本,而且我是 Azure DevOps 的新手。这个 html 文件必须与构建工件一起编译和生成。我不确定我是怎么做的。有人可以指出我在何处输出发行说明的正确方向吗?我是否需要根据 stagingdirectory、agent 添加文件路径?
- task: PowerShell@2
displayName: "Generate release notes"
inputs:
targettype: 'inline'
script: |
// some stuff that's irrelevant
[string]$fileName = ".\ReleaseNotes.html"
$releaseNotesHtml = "<!DOCTYPE html><html><head><title>Release Notes for" +
$applicationName + "</title></head>" +
"<body>"
foreach($item in $workItemResponse.value)
{
$releaseNotesHtml +=
"<div>" +
"<h4>" + $item.fields.'System.WorkItemType' + " " +
$item.fields.'System.Title' + "</h4>" +
"<b>Description</b><br/>" +
"<p>" + $item.fields.'System.Description' + "</p>" +
"</div>"
}
$releaseNotesHtml += "</body></html>"
#=== Write the release notes to the output file ===
Write-Host "Starting to write release notes to: "$fileName
$releaseNotesHtml | out-file $fileName
Write-Host "Finished writing release notes"
解决方法
将文件复制到 $(Build.ArtifactStagingDirectory) 中,然后将其作为工件发布。见https://docs.microsoft.com/en-us/azure/devops/pipelines/artifacts/build-artifacts?view=azure-devops&tabs=yaml