Azure Devops管道运行会导致Git错误?

时间:2020-09-21 21:55:59

标签: git azure ssh continuous-integration azure-pipelines

操作: 我在我的工作azure devop上有一个git项目,该项目通常使用ssh身份验证进行提取。 我试图在我的工作azure devops上运行管道,并使用azure GUI运行自托管的Windows计算机来测试CI功能。这是一个问候词项目,只是测试所有设置是否正确。

已执行

在Azure Pipelines作业终端中看到“问候语”结果。

结果:

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

2020-09-21T20:35:25.0633203Z ##[command]git init "C:\agentW\_work\1\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 \ 1 \ s并使用 git remote set-url origin ssh ... 如此处指定:https://docs.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=azure-devops,然后手动拉动。成功了。

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

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

  4. 如果我需要将公共ssh密钥粘贴到某个地方,则需要访问C:\ Users *****(已编辑).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

1 个答案:

答案 0 :(得分:0)

这是一个临时解决方案, 但是我发现删除我的自托管代理并使用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