任务名称显示错误的模式,即使在YAML文件中匹配正确。

huangapple go评论72阅读模式
英文:

Task name shows wrong pattern even it matches correctly in the YAML file

问题

下面脚本的任务名称有什么问题:

我正在编写YAML脚本,用于从本地PostgreSQL数据库将数据复制到Azure PostgreSQL DB实例,通过Azure DevOps CI/CD管道,但出现了语法错误。

代码

pool:
  vmImage: ubuntu-latest

stages:
- stage: CopyData
  jobs:
  - job: CopyDataJob
    displayName: '将数据从本地PostgreSQL复制到Azure PostgreSQL'
    steps:
    - task: PostgreSQLScript@0
      displayName: '从本地PostgreSQL导出数据'
      inputs:
        connectionType: 'PostgreSQL'
        postgresqlFile: 'location.sql'
        postgresqlConnectionString: 'DATABASE_URL=postgres://{testuser2408}:{testuser2408!}@{localhost}:{5432}/{postgres}'
        failOnScriptError: true

    - task: CopyFiles@2
      displayName: '将导出的数据复制到构建工件暂存目录'
      inputs:
        SourceFolder: '$(Build.SourcesDirectory)'
        Contents: 'path/to/exported_data/*.csv'
        TargetFolder: '$(Build.ArtifactStagingDirectory)'
英文:

What is wrong in the task name of the below script:

任务名称显示错误的模式,即使在YAML文件中匹配正确。

I am writing the YAML Script for Data Copy from Local Postgre SQL Database to Azure PostgreSQL DB Instance through Azure DevOps CI/CD Pipelines but getting the syntax error

Code:

pool:
  vmImage: ubuntu-latest

stages:
- stage: CopyData
  jobs:
  - job: CopyDataJob
    displayName: 'Copy Data from Local PostgreSQL to Azure PostgreSQL'
    steps:
    - task: PostgreSQLScript@0
      displayName: 'Export Data from Local PostgreSQL'
      inputs:
        connectionType: 'PostgreSQL'
        postgresqlFile: 'location.sql'
        postgresqlConnectionString: 'DATABASE_URL=postgres://{testuser2408}:{testuser2408!}@{localhost}:{5432}/{postgres}'
        failOnScriptError: true

    - task: CopyFiles@2
      displayName: 'Copy Exported Data to Artifact Staging Directory'
      inputs:
        SourceFolder: '$(Build.SourcesDirectory)'
        Contents: 'path/to/exported_data/*.csv'
        TargetFolder: '$(Build.ArtifactStagingDirectory)'

答案1

得分: 0

发生此错误的原因是没有可用的任务 PostgreSQLScript@0。

要部署到 Azure PostgreSQL 服务器,Microsoft 建议使用 AzureCLI@2 任务

    - 任务: AzureCLI@2
      显示名称: Azure CLI
      输入:
        azureSubscription: <Azure 资源管理器服务连接的名称>
        scriptLocation: inlineScript
        arguments:
          -SERVERNAME mydemoserver ``
          -DBNAME pollsdb ``
          -DBUSER pollsdbuser``
          -DBPASSWORD pollsdbpassword
        inlineScript: |
          az login --allow-no-subscription
          az postgres flexible-server execute --name $(SERVERNAME) \
          --admin-user $(DBUSER) --admin-password '$(DBPASSWORD)' \
          --database-name $(DBNAME) --file-path /code/sql/db-schema-update.sql
英文:

The reason this error is occurring is due to the fact there is no task PostgreSQLScript@0 task available.

For deploying to an Azure PostgreSQL Server Microsoft recommends leveraging the AzureCLI@2 task

- task: AzureCLI@2
  displayName: Azure CLI
  inputs:
    azureSubscription: <Name of the Azure Resource Manager service connection>
    scriptLocation: inlineScript
    arguments:
      -SERVERNAME mydemoserver `
      -DBNAME pollsdb `
      -DBUSER pollsdbuser`
      -DBPASSWORD pollsdbpassword
    inlineScript: |
      az login --allow-no-subscription
      az postgres flexible-server execute --name $(SERVERNAME) \
      --admin-user $(DBUSER) --admin-password '$(DBPASSWORD)' \
      --database-name $(DBNAME) --file-path /code/sql/db-schema-update.sql

huangapple
  • 本文由 发表于 2023年6月22日 20:38:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76532003.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定