【问题标题】:Trying to deploy ionic5 angular8 pwa to aws ec2 from azure devops YAML尝试从 azure devops YAML 将 ionic5 angular8 pwa 部署到 aws ec2
【发布时间】:2021-01-26 10:38:45
【问题描述】:

我是 azure devops 的新手。我正在尝试通过 azure 管道在亚马逊 ec2 上部署我的 ionic5 angular 应用程序。每当我尝试运行管道时,它都会给出“解析管道 YAML 时遇到的错误: /build-ci.yml (Line: 2, Col: 3): A mapping was not expected”这个错误。 这是 yaml 文件代码。我被困在这里了。请帮忙。

trigger:
- task: CodeDeployDeployApplication@1
  inputs:
    awsCredentials: 'AWS Service Con'
    regionName: 'us-east-1'
    applicationName: 'Dev-erp-Frontend'
    deploymentGroupName: 'Dev-erp-Frontend'
    deploymentRevisionSource: 'workspace'
    revisionBundle: 'Dev-erp-Frontend-Rev'
    bucketName: 'Dev-erp-Frontend'
    fileExistsBehavior: 'OVERWRITE'
    batch: "true"
  branches:
    include:
      - master
      - dev
  paths:
    include:
      - ./*

pr:
  branches:
    include:
      - master
      - dev
  paths:
    include:
      - ./*

jobs:
  - job: Build_Job
    displayName: Build
    pool:
      vmImage: 'ubuntu-18.04'
      demands:
      - npm
    steps:
    - checkout: self
      clean: false
#    - powershell: 'npm cache clean  --force'
#      displayName: 'PowerShell Script'
#      env:
#        APPDATA: npm-cache
    - task: Npm@1
      displayName: 'Npm Install'
      inputs:
        workingDir: "./"
        command: "ci"
    - task: Npm@1
      displayName: 'Lint Client App'
      inputs:
        workingDir: "./"
        command: "custom"
        customCommand: "run lint"
      continueOnError: true
    - task: Npm@1
      displayName: 'Copy Assets'
      inputs:
        workingDir: "./"
        command: "custom"
        customCommand: "run copy-files"
      continueOnError: false
    - task: Npm@1
      displayName: 'Build Client App'
      inputs:
        workingDir: "./"
        command: "custom"
        customCommand: "run build:prod"

# Archive files
    - task: ArchiveFiles@2
      inputs:
        rootFolderOrFile: '$(Build.BinariesDirectory)' 
        includeRootFolder: true 
        archiveType: 'zip' # Options: zip, 7z, tar, wim
        archiveFile: '$(Build.ArtifactStagingDirectory)/www.zip' 
        replaceExistingArchive: true

    - task: CopyFiles@2
      inputs:
        Contents: 'www/**'
        TargetFolder: '$(build.artifactstagingdirectory)'
    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact'
      inputs:
        PathtoPublish: '$(build.artifactstagingdirectory)'
        ArtifactName: 'titas-ecom-erp'

【问题讨论】:

  • 嗨@Amitabh Biswas,这里有什么更新吗?请随时让我知道最新消息。或者,如果您有任何疑问,请随时在此处分享。
  • 暂时不用担心。 yaml 文件运行顺利。没有问题
  • 嗨@Amitabh Biswas,如果答案有帮助,我们可以accept it 作为答案,在这种情况下,其他人可以直接找到有用的解决方案。谢谢。

标签: azure amazon-ec2 yaml azure-pipelines


【解决方案1】:

我们不能在trigger level处设置任务CodeDeployDeployApplication@1,我们应该在steps level处添加task。您可以按如下方式更新您的 YAML 定义。

trigger:
  branches:
    include:
      - master
      - dev
  paths:
    include:
      - ./*

pr:
  branches:
    include:
      - master
      - dev
  paths:
    include:
      - ./*

jobs:
  - job: Build_Job
    displayName: Build
    pool:
      vmImage: 'ubuntu-18.04'
      demands:
      - npm
    steps:
    - checkout: self
      clean: false
#    - powershell: 'npm cache clean  --force'
#      displayName: 'PowerShell Script'
#      env:
#        APPDATA: npm-cache

    - task: CodeDeployDeployApplication@1
      inputs:
        awsCredentials: 'AWS Service Con'
        regionName: 'us-east-1'
        applicationName: 'Dev-erp-Frontend'
        deploymentGroupName: 'Dev-erp-Frontend'
        deploymentRevisionSource: 'workspace'
        revisionBundle: 'Dev-erp-Frontend-Rev'
        bucketName: 'Dev-erp-Frontend'
        fileExistsBehavior: 'OVERWRITE'
        batch: "true"

    - task: Npm@1
      displayName: 'Npm Install'
      inputs:
        workingDir: "./"
        command: "ci"
    - task: Npm@1
      displayName: 'Lint Client App'
      inputs:
        workingDir: "./"
        command: "custom"
        customCommand: "run lint"
      continueOnError: true
    - task: Npm@1
      displayName: 'Copy Assets'
      inputs:
        workingDir: "./"
        command: "custom"
        customCommand: "run copy-files"
      continueOnError: false
    - task: Npm@1
      displayName: 'Build Client App'
      inputs:
        workingDir: "./"
        command: "custom"
        customCommand: "run build:prod"

# Archive files
    - task: ArchiveFiles@2
      inputs:
        rootFolderOrFile: '$(Build.BinariesDirectory)' 
        includeRootFolder: true 
        archiveType: 'zip' # Options: zip, 7z, tar, wim
        archiveFile: '$(Build.ArtifactStagingDirectory)/www.zip' 
        replaceExistingArchive: true

    - task: CopyFiles@2
      inputs:
        Contents: 'www/**'
        TargetFolder: '$(build.artifactstagingdirectory)'
    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact'
      inputs:
        PathtoPublish: '$(build.artifactstagingdirectory)'
        ArtifactName: 'titas-ecom-erp'

【讨论】:

    猜你喜欢
    • 2019-11-16
    • 1970-01-01
    • 2019-11-27
    • 1970-01-01
    • 2020-11-10
    • 2020-02-04
    • 2015-07-04
    • 2021-05-26
    • 2013-09-23
    相关资源
    最近更新 更多