如何在powershell http post请求中将jenkins凭据参数作为身份验证标头传递
我正在尝试使用powershell访问下面的POST呼叫 通话后如何在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
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!真是个有趣的问题。