VSTS管道步骤PublishPipelineArtifact在清单部署任务上失败

时间:2020-09-11 13:24:13

标签: azure-devops azure-yaml-pipelines

VSTS为我自动创建了yaml管道。 在步骤PublishPipelineArtifact失败。

enter image description here

我对yaml语法不熟悉。
以下是自动生成的Yaml的摘录。关于清单的2个步骤。 但是,我的visual studio项目没有任何清单文件或目录,VSTS没有生成任何Deployment.yml或service.yml。 我不知道为什么它会失败,以及为什么这样的Yaml是用不存在的依赖关系生成的。 (如果我以图形标准方式创建管道(不要求yaml管道),则管道不会失败,并且不会生成清单部署步骤。

- stage: Build
  displayName: Build stage
  jobs:  
  - job: Build
    displayName: Build
    pool:
      name: "AWS Linux agents pool"
    steps:
    - checkout: Self
    - checkout: Shared
      path: s/File.Pod/Shared.Lib 
    - 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

- stage: Deploy
  displayName: Deploy stage
  dependsOn: Build

  jobs:
  - deployment: Deploy
    condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')))
    displayName: Deploy
    pool:
      name: "AWS Linux agents pool"
    environment: 'FilePod-1617.development'
    strategy:
      runOnce:
        deploy:
          steps:
          - task: KubernetesManifest@0
            displayName: Create imagePullSecret
            inputs:
              action: createSecret
              secretName: $(imagePullSecret)
              dockerRegistryEndpoint: $(dockerRegistryServiceConnection)
              
          - task: KubernetesManifest@0
            displayName: Deploy to Kubernetes cluster
            inputs:
              action: deploy
              manifests: |
                $(Pipeline.Workspace)/manifests/deployment.yml
                $(Pipeline.Workspace)/manifests/service.yml
              imagePullSecrets: |
                $(imagePullSecret)
              containers: |
                $(containerRegistry)/$(imageRepository):$(tag)

据我所知,清单文件夹存在于存储库中。 enter image description here

我是否需要在DockerFile中的某处要求复制它某处

分支是dev enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

我们可以看到该文件夹​​位于dev分支上,我们应该确保我们在dev分支而不是其他分支上运行yaml构建,否则,将得到错误:Path does not exist

示例YAML:

steps:

- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      # Write your PowerShell commands here.
      
      Write-Host "Hello World"

- upload: test01
  artifact: manifests

结果:

enter image description here

Update1:​​

enter image description here