Flo*_*mak 1 powershell azure-devops azure-pipelines
有没有办法从 PowerShell 脚本发布 Pipeline Artefact ?
我想避免创建额外的管道任务来发布文件。
代替:
      - task: PublishPipelineArtifact@1
        displayName: 'publish azuredeploy.parameters.json'
        inputs:
          targetPath: $(System.DefaultWorkingDirectory)/work
          artifactName: azuredeploy parameters
Run Code Online (Sandbox Code Playgroud)
我宁愿做这样的事情:
      - task: PowerShell@2
        displayName: 'replace ARM parameters'
        inputs:
          targetType: inline
          pwsh: true
          script: |
              # input
              $manifest = ReadObject "work/manifest.json"
              # process
              ReplaceArmTemplateParameters $manifest.modules
              # output
              PublishPipelineArtefact -targetPath "work/manifest.json" -artefactName "azuredeploy-parameters"
Run Code Online (Sandbox Code Playgroud)
也许构建代理提供了一个可以在PowerShell@2任务中使用的 API,例如:Agent.Plugins.PipelineArtifact.PublishPipelineArtifactTask::PipelineArtifactTaskPluginBaseV1
有任何想法吗?
(ps:这个问题好像有点过时了)
如果您希望它将成为脚本的一部分,您可以使用日志命令:
##vso[artifact.associate]artifact location- 创建工件链接,工件位置必须是文件容器路径、VC 路径或 UNC 共享路径。
##vso[artifact.upload]local file path- 将本地文件上传到文件容器文件夹中,如果提供了artifactname,则创建artifact。
您可以将其与 一起使用Write-Host,例如:
Write-Host "##vso[artifact.upload containerfolder=test;artifactname=drop;]c:\test.zip"
Run Code Online (Sandbox Code Playgroud)
另一种选择是不使用PublishPipelineArtifact@1任务,有更简单和更短的语法:
- publish: $(System.DefaultWorkingDirectory)/bin/WebApp
  artifact: WebApp
Run Code Online (Sandbox Code Playgroud)
        |   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           1917 次  |  
        
|   最近记录:  |