如何修复运行在多节点网络上的 Jenkins 脚本,脚本中的 curl 命令无法正常工作并输出“需要授权”

我有一个运行着的四节点网络,并希望在该网络上执行 curl 命令。在我的计算机上运行并 ssh 到一个节点足以完成测试,但是当将命令移动到 Jenkins 脚本中时,我会得到以下响应

<html>
<head><title>401 需要授权</title></head>
<body bgcolor="white">
<center><h1>401 需要授权</h1></center>
<hr><center>openresty/1.13.6.1</center>
</body>
</html>

其中第一个节点启用了 OAuth。如何解决这个问题?

我的网络运行在 AWS 节点上

    curl -X POST "http://<node1_IP>/bloc/v2.2/users/<account>/<address1>/send?resolve=true" -H "accept: application/json;charset=utf-8" -H "Content-Type: application/json;charset=utf-8" -d "{ \"toAddress\": \"<address2>\", \"value\": \"1\", \"password\": \"<password>\", \"metadata\": null, \"txParams\": null}"
        transactionHash=$(curl -X POST "http://<node1_IP>:8080/bloc/v2.2/users/t1/<address1>/send?resolve=true" -H "accept: application/json;charset=utf-8" -H "Content-Type: application/json;charset=utf-8" -d "{ \"toAddress\": \"<address2>\", \"value\": \"1\", \"password\": \"t1\", \"metadata\": null, \"txParams\": null}" | jq -r '.txResult' | jq -r '.transactionHash')
        echo "transactionHash: $transactionHash"
        transactionHash=$transactionHash

我希望第一个返回以 json 格式传输的数据,而对于第二个 curl 命令,我希望将字符串存储在 transactionHash 中。

点赞