azure-pipelines.yml 中的错误意外值 'steps'
Error Unexpected value 'steps' in azure-pipelines.yml
我试图在构建和部署之前将视频文件从 GPM 复制到 app/dist/asset/images 文件夹 docker image.Getting 第 27 行的意外值 'Steps'。
如果我删除复制视频文件的步骤,YML 文件可以正常工作。
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)
steps
属性 不应放在 stage
级别下。它是:stage=>job=>steps
因此,当您定义 multi-stage yaml 管道时,您不能将 steps
放在那里。
1.steps
可以直接放在第一层用于简单的 yaml 管道(无阶段):
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.它应该放在 multi-stage yaml 管道中的作业级别下:
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
根据您的 stages:
元素,您的管道将被识别为可用于构建和部署的 multi-stage 管道。所以你不能也不应该把 steps
直接放在 stages:
.
下面
解法:
要解决 Unexpected value 'Steps'
,您应该删除 steps
或将它们添加到一个阶段级别:
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)
我试图在构建和部署之前将视频文件从 GPM 复制到 app/dist/asset/images 文件夹 docker image.Getting 第 27 行的意外值 'Steps'。
如果我删除复制视频文件的步骤,YML 文件可以正常工作。
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)
steps
属性 不应放在 stage
级别下。它是:stage=>job=>steps
因此,当您定义 multi-stage yaml 管道时,您不能将 steps
放在那里。
1.steps
可以直接放在第一层用于简单的 yaml 管道(无阶段):
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.它应该放在 multi-stage yaml 管道中的作业级别下:
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
根据您的 stages:
元素,您的管道将被识别为可用于构建和部署的 multi-stage 管道。所以你不能也不应该把 steps
直接放在 stages:
.
解法:
要解决 Unexpected value 'Steps'
,您应该删除 steps
或将它们添加到一个阶段级别:
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)