我尝试在Jenkins管道中的ssh-agent上运行一些jq命令,但是我得到了以下错误:尝试运行:'
stage("common-infra-deployment"){
steps{
sshagent (credentials: ['test-private-key']){
script{
sh '''
sudo ssh -o StrictHostKeyChecking=no hci@10.x.x.x "
jq '.outputs | {"kubeconfig-file"}' terraform.tfstate;
"
'''
}
}
}
}
'
错误:'
jq: error: syntax error, unexpected '-', expecting '}' (Unix shell quoting issues?) at <top-level>, line 1:
'
地形
{
"outputs": {
"kubeconfig-file": {
"value": "/home/chi/jenkins-terraform/config",
"type": "string"
},
"master-node-ip": {
"value": "x.x.x.x",
"type": "string"
},
"master-node-vm-name": {
"value": "v1",
"type": "string"
},
"worker-node-ip": {
"value": "x.x.x.x, x.x.x.x, x.x.x.x",
"type": "string"
},
"worker-node-vm-names": {
"value": "v2, v3, v4",
"type": "string"
}
}
}
'
我试过\转义'-'和'{}',但没有成功。我希望jq在ssh会话上执行。
1条答案
按热度按时间6uxekuva1#
双引号内的双引号必须转义:
也许反斜杠本身需要转义: