Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在powershell http post请求中将jenkins凭据参数作为身份验证标头传递_Powershell_Jenkins Pipeline_Jenkins Groovy_Jenkins Cli - Fatal编程技术网

如何在powershell http post请求中将jenkins凭据参数作为身份验证标头传递

如何在powershell http post请求中将jenkins凭据参数作为身份验证标头传递,powershell,jenkins-pipeline,jenkins-groovy,jenkins-cli,Powershell,Jenkins Pipeline,Jenkins Groovy,Jenkins Cli,我正在尝试使用powershell访问下面的POST呼叫 通话后http://pathandport//computer/agentname/api/json?pretty=true 从jenkins调用一个powershell文件,该文件访问RESTAPI,用户名和密码以纯文本形式从jenkins传递 $pair= "$($username):$($password)" $encode= [System.Convert]::ToBase64String([System.Text.Encodin

我正在尝试使用powershell访问下面的POST呼叫 通话后
http://pathandport//computer/agentname/api/json?pretty=true

从jenkins调用一个powershell文件,该文件访问RESTAPI,用户名和密码以纯文本形式从jenkins传递

$pair= "$($username):$($password)"
$encode= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$Auth= "Basic $encode"
$Headers = @{ Authorization = $Auth }
$url = 'http://<path>:<port>//computer/agentname/api/json?pretty=true'
$response = Invoke-WebRequest -Uri $url -Headers $Headers
$pair=“$($username):$($password)”
$encode=[System.Convert]::tobase64字符串([System.Text.Encoding]::ASCII.GetBytes($pair))
$Auth=“基本$encode”
$Headers=@{Authorization=$Auth}
$url='http://:///computer/agentname/api/json?pretty=true'
$response=调用WebRequest-Uri$url-Headers$Headers
当我们以纯文本形式传递用户名和密码时,该场景运行良好

最近了解了jenkins credentials param(用户名和密码),它从中获取用户名和密码,使用内置逻辑将其编码为令牌,并生成类似于此“1234-abcd-5678-efgh”的值

我现在的问题是,我无法在具有上述实现的powershell请求中将此令牌作为身份验证值传递


请帮助我如何处理此问题

欢迎使用SO!真是个有趣的问题。欢迎来到SO!真是个有趣的问题。