基本身份验证与詹金斯HTTP请求插件 [英] Basic Auth with Jenkins http-request-plugin

查看:294
本文介绍了基本身份验证与詹金斯HTTP请求插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用Http Request Plugin做一个简单的POST请求。我的问题是获取凭据的工作。我已经设置了一个全局凭据 user:pass



但是在我的代码中尝试这样做$ /

  withCredentials([usernameColonPassword(credentialsId:'akamai',variable:'akamai')]){

def response = httpRequest url:requestUrl,contentType:requestContentType,httpMode:requestHttpMode,requestBody:requestContent,认证:akamai
echo状态:$ {response.status} \\\
Content:$ {response.content}
}

结果

  java.lang.IllegalStateException:验证'user:pass'不存在


解决方案

HTTP请求插件v1.8.18



配置系统> HTTP请求现在指出不推荐使用基本/摘要式身份验证,而是使用Jenkins凭据:

p>

I am trying to make a simple POST-request with the "Http Request Plugin". My problem is with getting the credentials to work. I have set a global credential, user:pass.

But trying this in my code

withCredentials([usernameColonPassword(credentialsId: 'akamai', variable: 'akamai')]) {

    def response = httpRequest url: requestUrl, contentType: requestContentType, httpMode: requestHttpMode, requestBody: requestContent, authentication: akamai
    echo "Status: ${response.status}\nContent: ${response.content}"
}

results in

java.lang.IllegalStateException: Authentication 'user:pass' doesn't exist anymore

解决方案

HTTP Request Plugin v1.8.18 now supports credentials in the Credentials Plugin (the HTTP Request Plugin v1.8.18 now depends on v2.1.3 of the Credentials Plugin).

To perform an HTTP request using a Jenkins credential you can use the following code:

def response = httpRequest authentication: 'credentialsID', url: "http://www.example.com"

where credentialsID is the ID of the credentials in Jenkins:

The basic credentials under Configure System > HTTP Request now states that the Basic/Digest Authentication is deprecated and to use Jenkins credentials instead:

这篇关于基本身份验证与詹金斯HTTP请求插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆