Azure Devops 管道 运行 出现 Git 错误?

Azure Devops Pipeline Run makes Git Error?

行动: 我在我的工作 azure devops 上有一个 git 项目,我通常使用 ssh 身份验证将其拉取。 我尝试在我的工作 azure devops 和工作自托管 windows 计算机上从 azure GUI 运行 管道来测试 CI 功能。这是一个 hello word 项目,只是测试是否一切设置正确。

预期:

从 Azure Pipelines 作业终端看到“Hello word”结果。

结果:

管道使用自动脚本和 运行 一些 git 命令 尝试使用错误的凭据初始化和获取 https 项目并失败。这是包含一些已编辑信息的日志。

2020-09-21T20:35:25.0633203Z ##[command]git init "C:\agentW\_work\s"
2020-09-21T20:35:25.1242756Z Initialized empty Git repository in C:/agentW/_work/1/s/.git/
2020-09-21T20:35:25.1279844Z ##[command]git remote add origin https://********(REDACTED)
2020-09-21T20:35:25.1703998Z ##[command]git config gc.auto 0
2020-09-21T20:35:25.2109482Z ##[command]git config --get-all http.https://********(REDACTED).extraheader
2020-09-21T20:35:25.2498108Z ##[command]git config --get-all http.proxy
2020-09-21T20:35:25.2898438Z ##[command]git -c http.extraheader="AUTHORIZATION: bearer ***" fetch --force --tags --prune --progress --no-recurse-submodules origin
2020-09-21T20:35:25.5928108Z fatal: unable to access 'https:********(REDACTED)': SSL certificate problem: unable to get local issuer certificate

信息:

  1. 我尝试转到 C:\agentW_work\s 并使用 git 远程设置-url origin ssh... 如此处指定:https://docs.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=azure-devops 并手动拉动。成功了。

  2. 我尝试将 C:\agentW.credentials authorizationUrl 和 oauthEndpointUrl 值更改为我们的 DevOps 给我的值。

  3. 我尝试 运行 在配置 #2 中使用 HTTP 设置连接另一个管道项目(来自其他个人 azure 存储库,但相同的自托管计算机),它有效。见下文。

  4. 我可以访问我的 C:\Users*****(已编辑).ssh,如果我需要将我的 public ssh 密钥粘贴到某处。

问题:

  1. 如何更改自动脚本的设置以改为提取我的 ssh 存储库?
  2. 如何更改我的 Https Git 设置,以便拉取 https 项目也可以吗?

配置#1: 工作计算机 + 工作 Azure DevOps。

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
  branches: 
    include:
      - feature/azure-pipelines
pool:
  name: Default
  demands:
    - agent.name -equals WORK

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

- script: |
    echo Add other tasks to build, test, and deploy your project.
    echo See https://aka.ms/yaml
  displayName: 'Run a multi-line script'

配置#2: 工作计算机 + 个人 Azure DevOps。

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
  branches: 
    include:
      - master
pool:
  name: Default
  demands:
    - agent.name -equals WORK

steps:
  - task: RunMATLABCommand@0
    inputs:
      command: runBatchT
  - task: RunMATLABTests@0
    inputs:
      testResultsJUnit: test-results/results.xml
      codeCoverageCobertura: code-coverage/coverage.xml
      sourceFolder: src;test
  - task: PublishTestResults@2
    condition: succeededOrFailed()
    inputs:
      testResultsFiles: test-results/results.xml
  - task: PublishCodeCoverageResults@1
    inputs:
      codeCoverageTool: Cobertura
      summaryFileLocation: code-coverage/coverage.xml

这是临时修复, 但是我发现删除我的自托管代理并使用 sslcert skip 创建一个新代理是有效的。

.\config.cmd --sslskipcertvalidation 

它会影响git脚本并修改这一行以使用ssl skip参数:

2020-09-22T12:34:55.3658192Z ##[command]git -c http.extraheader="AUTHORIZATION: bearer ***" -c http.sslVerify=false fetch --force --tags --prune --

来源:

  1. https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/certificate?view=azure-devops-2020

  2. https://confluence.atlassian.com/bitbucketserverkb/ssl-certificate-problem-unable-to-get-local-issuer-certificate-816521128.html