【发布时间】:2022-12-12 00:46:59
【问题描述】:
我正在尝试在 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:
`
terraform.tfstate `
{
"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"
}
}
}
`
我试图 \ 转义 '-' 和 '{}' 但没有成功。 我希望通过 ssh 会话执行 jq。
【问题讨论】:
标签: jenkins jenkins-pipeline sh jq ssh-agent