使用 UniversalPackages@0 发布文件 - “提供的路径无效。”

问题描述 投票:0回答:2

我正在尝试将文件 (Helloworld.txt) 发布到我的 Universal Packages 目录,以传递到我的 Release Piepline 中的不同阶段(使用

UniversalPackages@0
)。

我一辈子都想不出如何让它发挥作用。

我正在尝试关注这个知识库,但它让我感到困惑:

https://learn.microsoft.com/en-us/azure/devops/pipelines/artifacts/universal-packages?view=azure-devops&tabs=yaml

例如,我无法确定 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 发布到通用目录 (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 发布到通用目录”任务输出:

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 管道发布工件而不是尝试制作在发布管道期间再次使用相同的Helloworld.txt。但是,如果有人可以帮助我弄清楚如何将发布管道中创建的新文件发布到 Universal packages 目录中,我愿意接受不可避免的反对票。

azure-devops azure-pipelines azure-pipelines-release-pipeline
2个回答
0
投票

我建议你调用

exe
Build
中生成txt文件。然后将它们发布为工件以发布管道。然后你可以轻松地在发布管道中选择
HelloWord.txt
文件。

此任务可用于构建和发布管道。在构建和发布中应用此任务之间的区别只是您非常困惑的

Path to file(s) to publish
值。

对于Release管道:

如果你想要发布

HelloWord.txt
成包,只需点击,然后从中选择相应的文件
HelloWord.txt

那么,它的价值应该是多少

$(System.DefaultWorkingDirectory)/{Source alias}/{artifact name}/s/HelloWorld.txt
.

注意:当您将生成的

txt
放在Build管道中,然后将它们发布为
artifact
并在发布管道中使用时,将应用这种方式。


类似于Build pipeline,您也可以从该按钮中选择文件。对于它的 YAML 格式,只需输入文件名,如:

  inputs:
    command: publish
    publishDirectory: 'azure-pipelines.txt'
    vstsFeedPublish: '*****'
    vstsFeedPackagePublish: merlin
    versionOption: custom
    versionPublish: 0.0.1
    packagePublishDescription: published in 2019/12/2

如果 azure-pipelines.txt 文件在文件夹下,只需将其输入为

{folder name}/azure-pipelines.txt
.

在您的问题中,如果您想将文件生成和包发布都放在构建管道中。因为我不是很清楚你的

HellowWorld.exe
剧本怎么样。
HelloWorld.txt
的位置由您的脚本决定。如果您没有在脚本中定义生成的文件位置,默认情况下,此
txt
文件路径应与
exe
相同。根据您分享的图片,它的路径似乎是
HelloWorld EXE Folder/HelloWorld.txt
。我建议你可以先使用私人代理运行这个Build来确认它的(
.txt
)路径。


vstsFeedPublish 应该是您在项目中创建的现有提要。这里不能是管道执行前不存在的新名称


vstsFeedPackagePublish 是您希望它存储在提要中的包名称。以我为例,这里我将其命名为

merlin
。发布完成后:

您可以指定一个新名称或使用现有名称。使用新名称意味着在 Feed 中创建一个新包,而使用现有的只是意味着版本增量。


-2
投票

Debes ir a los permisos del feed en Artifacts y agregar “Project Collection Build Service (Organization)” con permisos de “Contributor”。 Una vez configurado volver a correr el pipeline.

© www.soinside.com 2019 - 2024. All rights reserved.