POST 请求在 box 上成功,但在 jenkins 上失败

POST request succeeds on box, but fails in jenkins

我有一个连接到 salesforce 并取回身份验证令牌的集成测试。

    public AuthenticationResponse getAuthenticationResponse()
{
    MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
    map.add("client_id", consumerKey);
    map.add("client_secret", consumerSecret);
    map.add("grant_type", GRANT_TYPE);
    map.add("username", username);
    map.add("password", password);

    return new RestTemplate().postForObject(LOGIN_URI, map, AuthenticationResponse.class);
}

^ 这是测试运行的代码。

    public void testConnect(){
    AuthenticationResponse response = dataDotComClient.getAuthenticationResponse();

    assertNotNull(response);
    assertNotNull(response.getAccess_token());
}

^ 这就是测试本身。

这在我的和其他台式机上运行良好。但是,它在 jenkins 中永远不起作用,总是返回一个 400 状态代码,后面没有真正的错误消息。我必须在 Jenkins 中做些什么才能允许 post 对外部站点的请求?

http 400 表示

错误请求 - 无效 URL” 要么 "HTTP Error 400. The request hostname is invalid."

请确保您的目标主机可以从 jenkins 机器访问。 尝试登录到 jenkins 机器和 运行 curl/telnet 命令来检查连接。