【问题标题】:Publish build artifact task results 'path does not exist' error发布构建工件任务结果“路径不存在”错误
【发布时间】:2021-03-24 21:37:35
【问题描述】:

我正在尝试使用默认的 Azure DevOps 模板将图像推送到 AKS:

stages:
- stage: Build
  displayName: Build stage
  jobs:  
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)
    steps:
    - task: Docker@2
      displayName: Build and push an image to container registry
      inputs:
        command: buildAndPush
        repository: $(imageRepository)
        dockerfile: $(dockerfilePath)
        containerRegistry: $(dockerRegistryServiceConnection)
        tags: |
          $(tag)

    - upload: manifests
      artifact: manifests

这会导致以下错误:

##[error]Path does not exist: /home/vsts/work/1/s/manifests

我尝试过使用默认发布任务

- task: PublishPipelineArtifact@1
  inputs:
    artifactName: 'manifests'
    path: 'manifests'

但这并没有改变任何东西。有人可以解释一下,这里发生了什么以及为什么 Msft 的默认模板不起作用?

【问题讨论】:

    标签: docker kubernetes azure-devops yaml


    【解决方案1】:

    好的 - 在这个阶段我必须管理,我对构建管道中的工件有一个彻底的误解。

    upload(已弃用)和 publish 任务是 Publish Pipeline Artifact 任务 (https://docs.microsoft.com/en-us/azure/devops/pipelines/artifacts/pipeline-artifacts?view=azure-devops&tabs=yaml) 的简写

    其次,publish 关键字后面的路径是要发布的相对文件夹。如果您使用 Azure DevOps 中的 Kubernetes 服务模板,它将在您的存储库的根目录上创建一个 manifest 文件夹,并使用部署和服务 yml 文件预填充它。

    我不希望它们在那里(并且一定是下意识地删除了文件夹),所以我移动了它们并修改了路径:

    - publish: $(System.DefaultWorkingDirectory)/Code/Database/Docker
      artifact: sql-drop
    

    (Docker 文件夹是我保存 Dockerfile、docker-compose、覆盖和所有其他用于启动容器的爵士乐的地方)

    现在在我的部署任务中,我需要注意,我不能使用存储库中的文字路径。我需要先下载神器,然后使用神器的名称——“sql-drop”作为文件夹名:

    steps:
    #current means the current pipline. shorthand sytnax
    - download: current
      # name from the aritfact specifed above
      artifact: sql-drop
    - task: KubernetesManifest@0
      displayName: Create imagePullSecret
      inputs:
        action: createSecret
        secretName: $(imagePullSecret)
        dockerRegistryEndpoint: $(dockerRegistryServiceConnection)
        
    - task: KubernetesManifest@0
      displayName: Deploy to Kubernetes cluster
      inputs:
        action: deploy
        # Use sql-drop as folder name and specify manifests
        manifests: |
          $(Pipeline.Workspace)/sql-drop/his-sql.dev.deployment.yml
          $(Pipeline.Workspace)/sql-drop/his-sql.dev.service.yml
        imagePullSecrets: |
          $(imagePullSecret)
        containers: |
          $(containerRegistry)/$(imageRepository):$(tag)
    

    【讨论】:

    • 太棒了!你可以接受这个答案。这将对其他用户有所帮助。谢谢
    • @KevinLu-MSFT 当然——我只有两天时间才能接受自己的答案。谢谢你提醒我:)
    猜你喜欢
    • 1970-01-01
    • 2021-01-04
    • 1970-01-01
    • 2022-10-24
    • 2016-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多