0

VSTS has created a yaml pipeline automatically for me. It fails at step PublishPipelineArtifact.

enter image description here

I'm not familiar with the yaml syntax.
Below is an extract of the auto generated yaml. 2 steps talk about manifests. However my visual studio project doesn't have any manifest file or directory and VSTS didn't generate any Deployment.yml or service.yml. I have no idea why it's failing and why such yaml was generated with such dependancies that do not exist. (if I create the pipeline with the graphical standard way (not asking for yaml pipelines), it does not fail and no manifest deployment step is generated).

- 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)

From what I see, the manifest folder exists in the repository. enter image description here

Do I need somewhere in DockerFile to ask to copy it somewhere

The branch is dev enter image description here

enter image description here

CloudAnywhere
  • 669
  • 1
  • 11
  • 27

1 Answers1

0

We can see that the folder is on the dev branch, we should ensure that we are run the yaml build on the dev branch instead of other branches, if not, we will get the error: Path does not exist

Sample YAML:

steps:

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

- upload: test01
  artifact: manifests

Result:

enter image description here

Update1:

enter image description here

Vito Liu
  • 7,525
  • 1
  • 8
  • 17
  • The problem is with : - upload: test01 artifact: manifests ( prependPath mentioned here does not work : https://github.com/microsoft/azure-pipelines-yaml/blob/master/design/pipeline-artifacts.md). I ended up removing the upload step and moving it into a release pipeline – CloudAnywhere Sep 15 '20 at 07:00
  • Hi @CloudAnywhere, publish artifacts, could you please check this [doc](https://learn.microsoft.com/en-us/azure/devops/pipelines/artifacts/build-artifacts?view=azure-devops&tabs=yaml)? If the yaml build running branch does not have the file and you want to upload it, you will get the error: Path does not exist, you need to check it. In the error screenshot, it seems that the running branch is not dev. – Vito Liu Sep 15 '20 at 07:58
  • I confirm that, it is definitely the dev branch. We are in multirepository. 7ddd143..cd51e27 dev -> origin/dev Checkout File.Pod@dev to s/File.Pod The working directory is s/File.Pod and the error is Path does not exist: /home/bitnami/vstsagent/_work/17/s/manifests because obviously we should be in /s/File.Pod/manifests. As said earlier I tried PreprendPath to change the directory but it did not work – CloudAnywhere Sep 16 '20 at 08:12
  • Hi @CloudAnywhere, could please check the update1 and share a screenshot of the yaml build with us? In addition, please also share the full log with me, I need check it and ensure the issue. Thanks. – Vito Liu Sep 16 '20 at 10:28
  • Hi @CloudAnywhere, How about the issue? Does the answer below resolved your question, If not, would you please let me know the latest information about this issue? – Vito Liu Sep 21 '20 at 09:33
  • added 2 screenshots. The branch is dev. The 2 screenshots show that it is dev. I have precisely qualified the issue: The path context is /s/File.POD because of the multirepository context. It is looking for the manifest folder in /s/manifest. This is wrong. It should search in /s/file.pod/manifest. This is the issue and preprendpath is not working. – CloudAnywhere Sep 22 '20 at 11:38
  • Thanks for your sharing, could you please add your answer and accept it? In this case, others could directly find the useful solution. Thanks. – Vito Liu Sep 25 '20 at 10:06
  • Actually there is no answer. It does not work and we gave up: we built the image and stopped at this point ( removed the upload section and did it out of the pipeline process). – CloudAnywhere Oct 07 '20 at 07:16