我正在尝试将一个文件(Helloworld.txt)发布到我的通用软件包目录中,以传递到我发布的Piepline中的另一个阶段(使用UniversalPackages@0)。
我想不出怎样才能让它发挥作用。
我试图遵循这个KB,但它让我感到困惑:
例如,我无法确定vstsFeedPublish是什么,也不知道vstsFeedPackagePublish是否可以是我当场补上的新名称,或者是否实际上是现有文件/文件夹的名称。
我错误地输入了什么“路径”使它失败了?
阶段部署步骤:

Helloworld输出到TXT:
cd $(Build.ArtifactStagingDirectory)
"$(System.DefaultWorkingDirectory)/Helloworld Build/Helloworld EXE Folder/Helloworld.exe" >> WriteLineOutput.txt我首先将cd转换为$(Build.ArtifactStagingDirectory),因为这是UniversalPackages@0用于发布文件的默认文件夹,因此我希望在那里生成WriteLineOutput.txt。
将输出TXT发布到通用Dir (YAML):
steps:
- task: UniversalPackages@0
  displayName: 'Publish Output TXT to Universal Dir'
  inputs:
    command: publish
    vstsFeed: '0a3a9abd-83fd-495f-967b-e986c523f2d2'
    vstsPackageVersion: 1
    vstsFeedPublish: '0a3a9abd-83fd-495f-967b-e986c523f2d2'
    vstsFeedPackagePublish: 'writelineoutput-txt'
    versionOption: minor
    packagePublishDescription: 'TXT output from Helloworld.exe'工作目录结构:

“发布输出TXT到通用Dir”任务输出:
2019-12-02T03:35:35.2264352Z ##[section]Starting: Publish Output TXT to Universal Dir
2019-12-02T03:35:35.2381247Z ==============================================================================
2019-12-02T03:35:35.2381328Z Task         : Universal packages
2019-12-02T03:35:35.2381359Z Description  : Download or publish Universal Packages
2019-12-02T03:35:35.2381412Z Version      : 0.160.1
2019-12-02T03:35:35.2381461Z Author       : Microsoft Corporation
2019-12-02T03:35:35.2381490Z Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks
2019-12-02T03:35:35.2381520Z ==============================================================================
2019-12-02T03:35:36.0651445Z SYSTEMVSSCONNECTION exists true
2019-12-02T03:35:36.6058302Z Downloading: https://0t3vsblobprodcus362.vsblob.vsassets.io/artifacttool/artifacttool-win10-x64-Release_0.2.128.zip?sv=2017-04-17&sr=b&sig=tHZQU3V2DuXcC0Y1xnmzB7Zw7kMdjJSijWVDiztc9UE%3D&spr=https&se=2019-12-02T04%3A35%3A37Z&sp=r&P1=1575261037&P2=11&P3=2&P4=LS6Ffab5P%2bb8Q9r3aGsGLlK9ELRD6bRxxlTkDc5aEc8%3d
2019-12-02T03:35:39.3862184Z Caching tool: ArtifactTool 0.2.128 x64
2019-12-02T03:35:40.4414172Z SYSTEMVSSCONNECTION exists true
2019-12-02T03:35:41.4415128Z Publishing package: writelineoutput-txt, version: 0.1.0 using feed id: 65dc653c-5c3b-771c-b308-34b199d8fcee, project: null
2019-12-02T03:35:41.4469092Z [command]C:\hostedtoolcache\windows\ArtifactTool\0.2.128\x64\ArtifactTool.exe universal publish --feed 65dc653c-5c3b-771c-b308-34b199d8fcee --service https://vsrm.dev.azure.com/sawtooth-capstone/ --package-name writelineoutput-txt --package-version 0.1.0 --path D:\a\r1\a\$(Build.ArtifactStagingDirectory) --patvar UNIVERSAL_PUBLISH_PAT --verbosity None --description "TXT output from Helloworld.exe"
2019-12-02T03:35:44.0492154Z {"@t":"2019-12-02T03:35:43.3152933Z","@m":"ApplicationInsightsTelemetrySender will correlate events with X-TFS-Session 23e076ea-5122-4c06-b92a-2aef5974defd","@i":"8778ba0f","SourceContext":"ArtifactTool.Commands.UPackPublishCommand","UtcTimestamp":"2019-12-02 03:35:43.315Z"}
2019-12-02T03:35:44.0493421Z {"@t":"2019-12-02T03:35:43.7170274Z","@m":"Ensuring that the package does not yet exist...","@i":"40e01e14","SourceContext":"ArtifactTool.Commands.UPackPublishCommand","UtcTimestamp":"2019-12-02 03:35:43.717Z"}
2019-12-02T03:35:44.0494251Z {"@t":"2019-12-02T03:35:43.8900269Z","@m":"Package does not yet exist","@i":"c781eca5","SourceContext":"ArtifactTool.Commands.UPackPublishCommand","UtcTimestamp":"2019-12-02 03:35:43.890Z"}
2019-12-02T03:35:44.0494769Z {"@t":"2019-12-02T03:35:43.8913512Z","@m":"Pushing content...","@i":"3aa40378","SourceContext":"ArtifactTool.Commands.UPackPublishCommand","UtcTimestamp":"2019-12-02 03:35:43.891Z"}
2019-12-02T03:35:44.0495859Z {"@t":"2019-12-02T03:35:43.9060246Z","@m":"DedupManifestArtifactClient will correlate http requests with X-TFS-Session 23e076ea-5122-4c06-b92a-2aef5974defd","@i":"09a6f3ce","SourceContext":"ArtifactTool.Commands.UPackPublishCommand","UtcTimestamp":"2019-12-02 03:35:43.906Z"}
2019-12-02T03:35:44.0496478Z {"@t":"2019-12-02T03:35:44.0301714Z","@m":"The path provided is invalid.","@i":"05178f7d","@l":"Error","SourceContext":"ArtifactTool.Program","UtcTimestamp":"2019-12-02 03:35:44.030Z"}
2019-12-02T03:35:44.0776082Z ##[error]Error: An unexpected error occurred while trying to push the package. Exit code(16) and error({"@t":"2019-12-02T03:35:43.3152933Z","@m":"ApplicationInsightsTelemetrySender will correlate events with X-TFS-Session 23e076ea-5122-4c06-b92a-2aef5974defd","@i":"8778ba0f","SourceContext":"ArtifactTool.Commands.UPackPublishCommand","UtcTimestamp":"2019-12-02 03:35:43.315Z"}
{"@t":"2019-12-02T03:35:43.7170274Z","@m":"Ensuring that the package does not yet exist...","@i":"40e01e14","SourceContext":"ArtifactTool.Commands.UPackPublishCommand","UtcTimestamp":"2019-12-02 03:35:43.717Z"}
{"@t":"2019-12-02T03:35:43.8900269Z","@m":"Package does not yet exist","@i":"c781eca5","SourceContext":"ArtifactTool.Commands.UPackPublishCommand","UtcTimestamp":"2019-12-02 03:35:43.890Z"}
{"@t":"2019-12-02T03:35:43.8913512Z","@m":"Pushing content...","@i":"3aa40378","SourceContext":"ArtifactTool.Commands.UPackPublishCommand","UtcTimestamp":"2019-12-02 03:35:43.891Z"}
{"@t":"2019-12-02T03:35:43.9060246Z","@m":"DedupManifestArtifactClient will correlate http requests with X-TFS-Session 23e076ea-5122-4c06-b92a-2aef5974defd","@i":"09a6f3ce","SourceContext":"ArtifactTool.Commands.UPackPublishCommand","UtcTimestamp":"2019-12-02 03:35:43.906Z"}
{"@t":"2019-12-02T03:35:44.0301714Z","@m":"The path provided is invalid.","@i":"05178f7d","@l":"Error","SourceContext":"ArtifactTool.Program","UtcTimestamp":"2019-12-02 03:35:44.030Z"})
2019-12-02T03:35:44.0789627Z ##[error]Packages failed to publish
2019-12-02T03:35:44.0898947Z ##[section]Finishing: Publish Output TXT to Universal Dir关键线路:
2019-12-02T03:35:44.0496478Z {"@t":"2019-12-02T03:35:44.0301714Z","@m":"The path provided is invalid.","@i":"05178f7d","@l":"Error","SourceContext":"ArtifactTool.Program","UtcTimestamp":"2019-12-02 03:35:44.030Z"}
2019-12-02T03:35:44.0776082Z ##[error]Error: An unexpected error occurred while trying to push the package. Exit code(16) and error({"@t":"2019-12-02T03:35:43.3152933Z","@m":"ApplicationInsightsTelemetrySender will correlate events with X-TFS-Session 23e076ea-5122-4c06-b92a-2aef5974defd","@i":"8778ba0f","SourceContext":"ArtifactTool.Commands.UPackPublishCommand","UtcTimestamp":"2019-12-02 03:35:43.315Z"}编辑:
嗯,我读到了使用Build管道发布工件和使用 Release 管道运行/测试工件的最佳实践,因此我决定只发布Build管道中的工件,而不是在发布管道期间再次尝试制作相同的。但是,如果有人能帮助我将发布管道中创建的新文件发布到通用软件包目录中,我愿意接受不可避免的否决。
发布于 2019-12-02 10:15:59
我建议您调用exe在Build中生成txt文件。然后将它们作为工件发布管道。然后,您可以轻松地选择发布管道中的HelloWord.txt文件。
此任务既可用于生成管道,也可用于发布管道。在构建和发布中应用此任务之间的区别仅仅是您非常困惑的Path to file(s) to publish值。
对于发布管道:
如果要将HelloWord.txt发布到包中,只需单击

,然后从其中选择相应的文件HelloWord.txt。

所以,它的价值应该是$(System.DefaultWorkingDirectory)/{Source alias}/{artifact name}/s/HelloWorld.txt。
注意:当您将生成的txt放在生成管道中,然后将它们作为artifact发布并用于发布管道时,就会应用这种方法。
类似于Build管线,您也可以从该按钮中选择文件。对于YAML格式,只需输入文件名如下:
  inputs:
    command: publish
    publishDirectory: 'azure-pipelines.txt'
    vstsFeedPublish: '*****'
    vstsFeedPackagePublish: merlin
    versionOption: custom
    versionPublish: 0.0.1
    packagePublishDescription: published in 2019/12/2如果azure-管线. just文件位于文件夹下,只需将其作为{folder name}/azure-pipelines.txt输入即可。
在您的问题中,如果您希望将文件生成和包发布都放在构建管道中。因为我不太清楚您的HellowWorld.exe脚本是什么样的。HelloWorld.txt的位置由您的脚本决定。如果您没有在脚本中定义生成的文件位置,默认情况下,此txt文件路径应该与exe相同。根据您分享的图片,它的路径似乎是HelloWorld EXE Folder/HelloWorld.txt。我建议您可以首先使用私有代理来运行此构建,以确认其(.txt)路径。
vstsFeedPublish应该是您在项目中创建的现有提要。在这里,不能是执行管道之前不存在的新名称。
vstsFeedPackagePublish是您希望它存储在提要中的包名。作为示例,这里我将其命名为merlin。发行完成后:

您可以指定一个新名称或使用已存在的名称。使用一个新的名称意味着在Feed中创建一个新的包,而使用现有的名称仅仅意味着版本的增量。
https://stackoverflow.com/questions/59132520
复制相似问题