如何将 curl -LO 转换为 windows 或 groovy 命令?

How to convert curl -LO to a windows or groovy command?

我需要在 Jenkins 的 windows 节点上安装 kubectl https://v1-19.docs.kubernetes.io/docs/tasks/tools/install-kubectl/

我没有安装 curl,我想按照确切的步骤安装 kubectl

curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.19.14/bin/windows/amd64/kubectl.exe

有什么建议吗? link 中的另一个 powershell 命令对我不起作用。 编辑:正如我在评论中提到的,我试过:

Invoke-WebRequest "storage.googleapis.com/kubernetes-release/release/v1.19.14/bin/…" -OutFile "kubectl.exe

但是脚本只是 运行 并且永远不会停止 控制台只显示:

[Pipeline] powershell

cmd + powershell

PowerShell.exe -Command "&{$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest https://storage.googleapis.com/kubernetes-release/release/v1.19.14/bin/windows/amd64/kubectl.exe -OutFile kubectl.exe}"

普通groovy

new URL('https://storage.googleapis.com/kubernetes-release/release/v1.19.14/bin/windows/amd64/kubectl.exe').withInputStream{
    new File('/.tmp/kubectl.exe') << it
}

groovy 没有 withInputStream

def url = new URL('https://storage.googleapis.com/kubernetes-release/release/v1.19.14/bin/windows/amd64/kubectl.exe')
def stream = url.openStream()
new File('/.tmp/kubectl.exe') << stream
stream.close()