我想用“Http请求插件”做一个简单的POST请求。我的问题是获取凭据的工作。我已设置全球凭证user:pass
。Jenkins的基本身份验证http请求插件
但在我的代码尝试这种
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}"
}
结果
java.lang.IllegalStateException: Authentication 'user:pass' doesn't exist anymore
我照你的答案也提到,但我得到的错误 - java.lang.IllegalStateException相同:认证“CredentialsID”不存在了 –
你有存储在詹金斯与凭证ID“CredentialsID”?如果您在Jenkins中查看证书,它将显示一个包含(除其他外)每个存储凭证的名称和ID的表格。这是你想使用的ID字段 –
是的,我已经在Jenkins中创建了一个凭据,就像你在答案中提到的那样,然后我使用该Credetial的ID。我提到的细节有问题 - https://stackoverflow.com/questions/48166066/http-request-using-jenkins-pipeline-job –