无法下载在先前构建中生成的工件。

huangapple go评论86阅读模式
英文:

Cannot download artifact that was generated in a previous build

问题

我试图将一些数据从一个流水线运行持久化到另一个流水线。基本上,我的流水线工作方式如下:

  • 首先下载数据,如果存在的话(数据是一个包含数字的文本文件)
  • 运行一个脚本,将使用该数据(如果存在)并生成一些新数据
  • 发布新数据

运行脚本和发布文件都正常工作,因为我可以在流水线报告中看到有一个已发布的包含正确文件的构件。

然而,下载文件总是失败,它简单地显示了这个:

##[error]Artifact CheckWebsiteState was not found for build 10470.
Finishing: Download artifact

这是我使用的 YAML 脚本:

name: $(Date:yyyyMMdd)$(Rev:-r)

trigger: none

pool:
  vmImage: 'ubuntu-latest'

stages:
- stage: CheckWebsite

  jobs:
  - job: Run
    
    steps:

    - download: current
      artifact: CheckWebsiteState
      displayName: 'Download artifact'
      continueOnError: true

    - task: AWSShellScript@1
      displayName: CheckWebsite
      inputs:
        filePath: '$(System.DefaultWorkingDirectory)/scripts/check-website.sh'
        arguments: '$(Pipeline.Workspace)'

    - publish: $(Pipeline.Workspace)
      artifact: CheckWebsiteState
      displayName: 'Publish artifact'

有任何可能导致问题的想法吗?

英文:

I'm trying to persist some data from one pipeline run to another. Essentially my pipeline works like this:

  • First download the data, if it exists (the data is a text file with a number in it)
  • Run a script, that will use that data (if it exists), and generate some new one
  • Publish the new data

Running the script works and publishing the file too as I can see in the pipeline report that there's one published artifact with the right file in it.

However, downloading the file always fail, it simply says this:

##[error]Artifact CheckWebsiteState was not found for build 10470.
Finishing: Download artifact

This is the YAML script I'm using:

name: $(Date:yyyyMMdd)$(Rev:-r)

trigger: none

pool:
  vmImage: 'ubuntu-latest'

stages:
- stage: CheckWebsite

  jobs:
  - job: Run
    
    steps:

    - download: current
      artifact: CheckWebsiteState
      displayName: 'Download artifact'
      continueOnError: true

    - task: AWSShellScript@1
      displayName: CheckWebsite
      inputs:
        filePath: '$(System.DefaultWorkingDirectory)/scripts/check-website.sh'
        arguments: '$(Pipeline.Workspace)'

    - publish: $(Pipeline.Workspace)
      artifact: CheckWebsiteState
      displayName: 'Publish artifact'

Any idea what might be the issue?

答案1

得分: 1

我相信你试图从错误的流水线下载构件。你需要提供正确的“流水线资源标识符”,而不是指定“current”。举例来说,假设我想从我的流水线A模板中下载在流水线B中发布的构件。我的模板会看起来类似于以下内容。

trigger: none

# 在下载之前,你需要正确定义流水线资源。
# 你需要小心确保选择了你想要的流水线构建
# 我下面的定义将选择最近的、成功的流水线运行,来自流水线B,
# 针对主分支,在其中添加了一个`ScriptReady`构建标签。
# 你可以使用标签来确保选择了正确的流水线构建
resources:
  pipelines:
  - pipeline: pipelineB
    source: pipelines/pipelineB
    branch: main
    tags:
    - ScriptReady

stages:
- stage: CheckWebsite

  jobs:
  - job: Run
    
    steps:
    - download: pipelineB
      artifact: CheckWebsiteState
      displayName: '下载构件'
      continueOnError: true
英文:

I believe you are trying to download the artifact from the wrong pipeline. Instead of specifying current, you need to provide the right pipeline resource identifier. For example, let's say I want to download artifacts published in pipeline B from within my pipeline A template. My template would look something like the following.

trigger: none

# You need to define the pipeline resource correctly before you can download from it. 
# You will need to be careful to ensure the pipeline build you want gets selected
# My definition below will select the most recent, successful pipeline run from pipeline B 
# against the main branch, that has had a `ScriptReady` build tag added. You can use a
# tag to ensure the right pipeline build is being selected
resources:
  pipelines:
  - pipeline: pipelineB
    source: pipelines/pipelineB
    brain: main
    tags:
    - ScriptReady

stages:
- stage: CheckWebsite

  jobs:
  - job: Run
    
    steps:
    - download: pipelineB
      artifact: CheckWebsiteState
      displayName: 'Download artifact'
      continueOnError: true

huangapple
  • 本文由 发表于 2023年7月23日 22:47:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76748863.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定