Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Unexpected value 'steps' in azure-pipelines.yml

I am trying to copy a video file from GPM to app/dist/asset/images folder before building and deploying docker image.Getting Unexpected value 'Steps' at line 27.

YML file works fine if I remove the step to copy the video file.

azure-pipelines.yml

    trigger:
  branches:
    include: ['*']

pool:
  name: Default

# templates repo
resources:
  repositories:
    - repository: templates
      type: git
      name: comp.app.common.devops-templates
      ref: master

# Global Variables
variables:
  # necessary variables defined in this template
  - template: azure-templates/vars/abc-vars.yml@templates
  - name: dockerRepoName
    value: 'docker-it/library/xyz'
  # needed for k8 deployment
  - name: helmReleaseName
    value: xyz

stages:
  - steps:
    - bash: 'curl -o aa.mp4 https://gpm.mmm.com/endpoints/Application/content/xyz/bb.mp4'
      workingDirectory: '$(System.DefaultWorkingDirectory)/_hh_app/drop/app/dist/assets/images'
      displayName: 'Download Assets'

  # template to build and deploy
  - template: azure-templates/stages/angular-express-docker.yml@templates
    parameters:
      dockerRepoName: $(dockerRepoName)

    # deploy to rancher
  - template: azure-templates/stages/deploy-k8-npm.yml@templates
    parameters:
      helmReleaseName: $(helmReleaseName)
like image 829
Jan69 Avatar asked Aug 05 '20 19:08

Jan69


1 Answers

steps property should not be put under stage level. It's: stage=>job=>steps

So you can't place the steps there when you're defining a multi-stage yaml pipeline.

1.steps can be placed directly at first level for simple yaml pipeline (no stages):

trigger:
- master

pool:
  vmImage: 'windows-latest'

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

- script: |
    echo Add other tasks to build, test, and deploy your project.
  displayName: 'Run a multi-line script'

2.It should be put under jobs level within multi-stage yaml pipeline:

stages:
- stage: build
  displayName: Build
  jobs:
  - job: Build
    pool:
      name: xxx
    steps:
      - task: CmdLine@2
        inputs:
          script: |
            echo Hello world

- stage: deploy
  displayName: Release
  jobs:
  - job: Release
    pool:
      name: xxx
    steps:
      - task: CmdLine@2
        inputs:
          script: |
            echo Hello world

According to your stages: element, your pipeline will be recognized as a multi-stage pipeline that can be used to build and deploy. So you can't and shouldn't put steps directly under stages:.

Solution:

To resolve Unexpected value 'Steps', you should either remove the steps or add them into one stage level:

stages:
  - stage: First
    displayName: FirstStage
    jobs:
    - job: FirstJob
      pool:
        name: xxx
      steps:
      - bash: 'curl -o aa.mp4 https://gpm.mmm.com/endpoints/Application/content/xyz/bb.mp4'
        workingDirectory: '$(System.DefaultWorkingDirectory)/_hh_app/drop/app/dist/assets/images'
        displayName: 'Download Assets'

  # template to build and deploy
  - template: azure-templates/stages/angular-express-docker.yml@templates
    parameters:
      dockerRepoName: $(dockerRepoName)

    # deploy to rancher
  - template: azure-templates/stages/deploy-k8-npm.yml@templates
    parameters:
      helmReleaseName: $(helmReleaseName)
like image 143
LoLance Avatar answered Oct 11 '22 15:10

LoLance