从 .yaml 文件部署到 azure devops 时出现文件结尾错误?

时间:2021-02-24 14:22:02

标签: azure-devops yaml line-endings

从 . yaml文件

我尝试将 git config --global core.autocrlf 设置为 true,但没有用。

错误:

/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/3593ff85-827d-4f46-b0bc-685e80981d5c.sh 
warning: CRLF will be replaced by LF in GTVisualization/src/gtvisualization.py. 
The file will have its original line endings in your working directory 
diff --git a/GTVisualization/src/gtvisualization.py b/GTVisualization/src/gtvisualization.py 
index f42a167..7fe52ae 100644 
--- a/GTVisualization/src/gtvisualization.py 
+++ b/GTVisualization/src/gtvisualization.py

这是我的 yaml 文件:

# Docker
# Build a Docker image
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
 
trigger:
  - master
 
resources:
  - repo: self
 
variables:
  tag: "$(Build.BuildId)"
  imageName: 'pipelines-pytest-docker'
  dockerfilePath: $(Build.SourcesDirectory)/GTEstimation/Dockerfile
  workdir: /opt/app
 
stages:
  - stage: Check
    jobs:
      - job: CheckJob
        displayName: Build
        pool:
          vmImage: "ubuntu-latest"
        steps:
          - task: Cache@2
            inputs:
              key: "$(Agent.OS) | docker | db-lz-check"
              path: $(Pipeline.Workspace)/docker
              cacheHitVar: DOCKER_CACHE_RESTORED
            displayName: "Caching Docker image"
          - checkout: self
            clean: true
            lfs: true
            path: src/
            displayName: "Check out repository"
          - script: git config --global core.autocrlf true
            displayName: "Line endings new"
          - script: git diff --exit-code
            displayName: "Line endings"
          - script: |
              docker load < $(Pipeline.Workspace)/docker/dockerfile-lint.tar
              docker load < $(Pipeline.Workspace)/docker/autopep8.tar
            condition: and(not(canceled()), eq(variables.DOCKER_CACHE_RESTORED, 'true'))
            displayName: "Load docker images"
          - script: |
              mkdir -p $(Pipeline.Workspace)/docker
              docker pull projectatomic/dockerfile-lint
              docker save projectatomic/dockerfile-lint > $(Pipeline.Workspace)/docker/dockerfile-lint.tar
              docker pull unibeautify/autopep8
              docker save unibeautify/autopep8 > $(Pipeline.Workspace)/docker/autopep8.tar
            condition: and(not(canceled()), or(failed(), ne(variables.DOCKER_CACHE_RESTORED, 'true')))
            displayName: "Store docker images to cache"
          - task: Bash@3
            inputs:
              targetType: "filePath"
              filePath: "ci-scripts/docker-linter.sh"
            displayName: "Docker linter"
          - task: Bash@3
            inputs:
              targetType: "filePath"
              filePath: "ci-scripts/python-formatter.sh"
            displayName: "Python format PEP 8"
  - stage: Build
    displayName: Build image
    jobs:
      - job: Build
        displayName: Build
        pool:
          vmImage: "ubuntu-latest"
        steps:
          - task: Docker@2
            displayName: Build an image
            inputs:
              command: build
              dockerfile: "$(Build.SourcesDirectory)/src/Dockerfile"
              tags: |
                $(tag)
  - stage: Test
    jobs:
      - job: Test
        pool:
         vmImage: "ubuntu-latest"
        steps:
        - task: Docker@2
          displayName: Build an image
          inputs:
             repository: $(imageName)
             command: build
             dockerfile: $(dockerfilePath)
             tags: |
              $(tag) 
        - script:
             docker run $(imageName):$(tag) bash -c "pylint $(workdir)/src/map_matched.py"
        - script:
             docker run $(imageName):$(tag) bash -c "pytest -v --cov-report xml --cov=. --junitxml=/tests/test-reports/pytest-report.xml"

由于我是 azure devops 和 docker 的新手,如果我走错了方向,请纠正我。

我的 git 属性文件有什么问题吗?下面是文件。

# .gitattributes
# More information about this file:
#   https://git-scm.com/docs/gitattributes
#
 
# Set default behavior to automatically normalize line endings.
* text=auto
* text eol=crlf

1 个答案:

答案 0 :(得分:0)

您应该使用 git config --global core.autocrlf false 而不是 git config --global core.autocrlf true。详情请参阅this ticket