About help regarding "HTTP-REQUEST" plugin

I am trying for GSoC 25 & I feel “Swagger / OpenAPI standardization for Jenkins REST API” as quite interesting for me but it is not allowed to contribute in it until allowed to for upcoming gsoc. I seems a plugin “http-request” which seems similar to it & want to contribute in it but I am stuck in initial steps as mentioned below, Can anybody help ?

  • I created a simple pipeline to test the issue in https://issues.jenkins.io/browse/JENKINS-68154
  • I build it through mvn hpi:run but it gives console log without considering the pipeline
  • When I tried with my local jenkins controller with sudo systemctl start jenkins it works as expected and print the Response for all builds.
    • My doubt is, what is issue with my “mvn hpi:run” jenkins controller, Am I doing in wrong way ? Please, Can anybody help ?

I guess you need some more plugins. The project itself only depends on the bare minimum to compile and test it.
Your sample requires declarative pipeline which is not included by default. So install the pipeline aggregator plugin that will make install all relevant plugin

Thank You sir, it worked !!!

As latest comment in JIRA - 68154 :

  • I’m encountering an issue with the round-trip tests in the HTTP Request plugin. When I run the tests, they fail with a 500 server error during the configSubmit phase (for example, for URLs like http://localhost:36357/jenkins/job/test2/configSubmit).

  • However, when I tried it on my local Jenkins instance, the pipeline runs successfully without any errors.

  • Additionally, I wanted to ask about adding the following pipelines and updating the code:

  • Pipelines :

def response = httpRequest(
 url: 'https://httpbin.org/headers',
 customHeaders: [[name: 'foo', value: 'bar']]
  )
def headerName1 = 'header'
def varName1 = 'abc'
def headerName2 = 'another-header'
def varName2 = 'xyz'
def headers = [
"${headerName1}": "${varName1}",
"${headerName2}": "${varName2}"
]
def response = httpRequest(url: 'https://httpbin.org/headers', customHeaders: 
headers)
  • Updated Code for HttpRequestStep.java and HttpRequest.java :
@DataBoundSetter
public void setCustomHeaders(Object customHeaders) {
    if (customHeaders instanceof List) {
        List<?> list = (List<?>) customHeaders;
        if (!list.isEmpty() && list.get(0) instanceof Map) {
            this.customHeaders = list.stream()
                    .map(entry -> {
                        Map<String, String> map = (Map<String, String>) entry;
                        return new HttpRequestNameValuePair(map.get("name"), map.get("value"));
                    })
                    .collect(Collectors.toList());
        } else {
            this.customHeaders = (List<HttpRequestNameValuePair>) customHeaders;
        }
    } else if (customHeaders instanceof Map) {
        this.customHeaders = ((Map<String, String>) customHeaders)
                .entrySet()
                .stream()
                .map(entry -> new HttpRequestNameValuePair(entry.getKey(), entry.getValue()))
                .collect(Collectors.toList());
    } else {
        throw new IllegalArgumentException("Unsupported type for customHeaders: " + customHeaders.getClass());
    }
}
  • Test for customHeaders in HttpRequestRoundTripTest.java & HttpRequestStepRoundTripTest.java

  @Test
    public void configRoundtripGroup3() throws Exception {
        configRoundTrip(before);

        List<HttpRequestNameValuePair> params = new ArrayList<>();
        params.add(new HttpRequestNameValuePair("param1","value1"));
        params.add(new HttpRequestNameValuePair("param2","value2"));

        RequestAction action = new RequestAction(new URL("http://www.domain.com/"),HttpMode.GET,null,params);
        List<RequestAction> actions = new ArrayList<>();
        actions.add(action);

        FormAuthentication formAuth = new FormAuthentication("keyname",actions);
        List<FormAuthentication> formAuthList = new ArrayList<>();
        formAuthList.add(formAuth);

        HttpRequestGlobalConfig.get().setFormAuthentications(formAuthList);
        configRoundTrip(before);

        List<HttpRequestNameValuePair> customHeaders = new ArrayList<>();
        customHeaders.add(new HttpRequestNameValuePair("param1","value1"));
        before.setCustomHeaders(customHeaders);
        configRoundTrip(before);
    }

 private void configRoundTrip(HttpRequest before) throws Exception {
        HttpRequest after = j.configRoundtrip(before);
        j.assertEqualBeans(before, after, "httpMode,passBuildParameters");
        j.assertEqualBeans(before, after, "url");
        j.assertEqualBeans(before, after, "validResponseCodes,validResponseContent");
        j.assertEqualBeans(before, after, "acceptType,contentType");
        j.assertEqualBeans(before, after, "uploadFile,multipartName");
        j.assertEqualBeans(before, after, "outputFile,timeout");
        j.assertEqualBeans(before, after, "consoleLogResponseBody");
        j.assertEqualBeans(before, after, "authentication");

        // Custom header check
        assertEquals(before.getCustomHeaders().size(),after.getCustomHeaders().size());
        for (int idx = 0; idx < before.getCustomHeaders().size(); idx++) {
          HttpRequestNameValuePair bnvp = before.getCustomHeaders().get(idx);
          HttpRequestNameValuePair anvp = after.getCustomHeaders().get(idx);
          assertEquals(bnvp.getName(),anvp.getName());
          assertEquals(bnvp.getValue(),anvp.getValue());
        }

        // Form authentication check
        List<FormAuthentication> beforeFas = HttpRequestGlobalConfig.get().getFormAuthentications();
        List<FormAuthentication> afterFas  = HttpRequestGlobalConfig.get().getFormAuthentications();
        assertEquals(beforeFas.size(), afterFas.size());
        for (int idx = 0; idx < beforeFas.size(); idx++) {
            FormAuthentication beforeFa = beforeFas.get(idx);
            FormAuthentication afterFa  = afterFas.get(idx);
            assertEquals(beforeFa.getKeyName(), afterFa.getKeyName());
            List<RequestAction> beforeActions = beforeFa.getActions();
            List<RequestAction> afterActions  = afterFa.getActions();
            assertEquals(beforeActions.size(), afterActions.size());
            for (int jdx = 0; jdx < beforeActions.size(); jdx ++) {
                RequestAction beforeAction = beforeActions.get(jdx);
                RequestAction afterAction  = afterActions.get(jdx);
                assertEquals(beforeAction.getUrl(), afterAction.getUrl());
                assertEquals(beforeAction.getMode(), afterAction.getMode());
                List<HttpRequestNameValuePair> beforeParams = beforeAction.getParams();
                List<HttpRequestNameValuePair> afterParams  = afterAction.getParams();
                assertEquals(beforeParams.size(), afterParams.size());
                for (int kdx = 0; kdx < beforeParams.size(); kdx++) {
                    HttpRequestNameValuePair beforeNvp = beforeParams.get(kdx);
                    HttpRequestNameValuePair afterNvp  = afterParams.get(kdx);
                    assertEquals(beforeNvp.getName(), afterNvp.getName());
                    assertEquals(beforeNvp.getValue(), afterNvp.getValue());
                }
            }
        }
    }
}

I wanted to know how I can integrate these updates properly. Do you think the issue could be related to the testing environment, or is there something else I should investigate further?" Anyone can help !!!