【问题标题】:Outputting HTML file in Azure DevOps build YML在 Azure DevOps 中输出 HTML 文件构建 YML
【发布时间】:2021-03-24 00:13:12
【问题描述】:

我有一个用于创建 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"

【问题讨论】:

    标签: powershell azure-devops powershell-3.0


    【解决方案1】:

    将文件复制到 $(Build.ArtifactStagingDirectory) 中,然后将其发布为工件。见https://docs.microsoft.com/en-us/azure/devops/pipelines/artifacts/build-artifacts?view=azure-devops&tabs=yaml

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-24
      • 1970-01-01
      • 2020-11-28
      • 1970-01-01
      • 2021-12-09
      相关资源
      最近更新 更多