我一直在Azure托管的Ubuntu池上运行我的管道,我的管道运行得很好。现在,我在Ubuntu服务器上配置了自托管代理,当运行我的管道时,它在git pull步骤中失败了。
trigger:
batch: true
branches:
include:
- main
paths:
include:
- rg-test-cmn-syd-01-bastion
#pool:
#vmImage: ubuntu-latest
pool:
name: self-hosted
demands:
- agent.name -equals devops-agent-01
variables:
environmentName: 'dev'
resource_group: '******'
workDirectory: 'myworkdir'
gitRepository: 'ssh://git@ssh.dev.azure.com/v3/myorg/myproject'
backendType: 'azurerm'
backendServiceArm: '***'
backendAzureRmSubscriptionId: '*******'
backendAzureRmResourceGroupName: '******'
backendAzureRmStorageAccountName: '*****'
backendAzureRmContainerName: '*****'
backendAzureRmKey: '$(resource_group).tfstate'
environmentServiceName: '*****'
stages :
- stage: terraform_plan
jobs:
- job: terraform_plan
displayName: "Terraform Plan"
steps:
- checkout: none
- task: InstallSSHKey@0
inputs:
knownHostsEntry: $(known_host)
sshPublicKey: '******'
sshKeySecureFile: 'testkey'
- task: CmdLine@2
displayName: 'Git pull $(workDirectory)'
inputs:
script: |
echo [command] git init
git init
echo [command] git sparse-checkout: $(workDirectory)
git config core.sparsecheckout true
echo $(workDirectory) >> .git/info/sparse-checkout
echo [command] git remote add $(gitRepository)
git remote add origin $(gitRepository)
echo ##[command] git fetch --progress --verbose --depth=1 origin main
git fetch --progress --verbose --depth=1 origin main
##echo ##[command] git pull --progress --verbose origin main
git pull --progress --verbose origin main
字符串
相同的管道在Azure托管代理上运行正常(已注解池详细信息),但在自托管代理上运行时会失败。任何线索什么可以在这里失踪。
下面是我得到的错误消息
##git pull --progress --verbose origin main
##[debug]workingDirectory=/myagent/_work/2/s
##[debug]check path : /myagent/_work/2/s
Generating script.
##[debug]Agent.Version=3.220.5
##[debug]agent.tempDirectory=/myagent/_work/_temp
##[debug]check path : /myagent/_work/_temp
========================== Starting Command Output ===========================
##[debug]which 'bash'
##[debug]found: '/usr/bin/bash'
##[debug]which '/usr/bin/bash'
##[debug]found: '/usr/bin/bash'
##[debug]/usr/bin/bash arg: --noprofile
##[debug]/usr/bin/bash arg: --norc
##[debug]/usr/bin/bash arg: /myagent/_work/_temp/229ea54f-8b84-413a-915a-5c29dab2b0fc.sh
##[debug]exec tool: /usr/bin/bash
##[debug]arguments:
##[debug] --noprofile
##[debug] --norc
##[debug] /myagent/_work/_temp/229ea54f-8b84-413a-915a-5c29dab2b0fc.sh
/usr/bin/bash --noprofile --norc /myagent/_work/_temp/229ea54f-8b84-413a-915a-5c29dab2b0fc.sh
git init
Reinitialized existing Git repository in /myagent/_work/2/s/.git/
git sparse-checkout: TESRT-Infra/common/rgname/
git remote add ssh://git@ssh.dev.azure.com/v3/***/***/***
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
型
2条答案
按热度按时间ffscu2ro1#
假设您已经验证了从自托管代理示例到ssh.dev.azure.com端口22上的www.example.com的连接(您可以使用telnet客户端和/或Test-TcpConnection),则似乎需要将Azure DevOps FQDN添加到known_hosts文件。你可以试试这个命令:
ssh-keyscan -t rsa ssh.dev.azure.com>> ~/.ssh/known_hosts
tkclm6bt2#
请在最开始时添加此任务
字符串
或修改现有安装。ssh关键步骤,如果你有它。
knownHostsEntry
中的值来自ssh-keyscan -t rsa ssh.dev.azure.com
,它将向~/.ssh/known_hosts
添加条目