Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-48126

http request not sent, with no log and pipeline end directly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: http-request-plugin
    • Labels:
      None
    • Environment:
      CloudBees Jenkins Enterprise 2.73.3.1-rolling
      http request plugin 1.8.21
      Google Chrome is up to date
      Version 62.0.3202.94 (Official Build) (64-bit)
      Java version java-1.8.0-openjdk-1.8.0.141-2.b16.el6_9.x86_64
    • Similar Issues:

      Description

      When we execute inside a pipeline this method :

       

      // Jenkins DSL Pipeline as code
      
      /**
       * Retrieve the release Id which contains the application Id in the content with the correct version to deploy
       * @param applicationId application Id define in CDD
       * @param applicationVersion application version to deploy define in the content of the CDD release
       * @param applicationName application name to deploy define in the content of the CDD release
       * @return the release Id
       */
      def getReleaseId(String applicationId, String applicationVersion, String applicationName) {
          // Get All releases which contains the application id
          def responseGetReleaseId = steps.httpRequest acceptType: 'APPLICATION_JSON',
                  consoleLogResponseBody: true,
                  authentication: 'CDD',
                  responseHandle: 'NONE',
                  url: "${BASE_URL}${CDD_RELEASES_ENDPOINT}?status=DESIGN&status=RUNNING&status=RUNNING_WITH_ERRORS&application=${applicationId}"
          def responseGetReleaseIdJSON = new JsonSlurper().parseText(responseGetReleaseId.getContent())
          def releaseID
          def numberOfReleasesRunning = responseGetReleaseIdJSON.totalResultsCount
      
          if (numberOfReleasesRunning == 0) {
              steps.error("There is no CDD releases define with this application: " + applicationName + ".")
          } else if (numberOfReleasesRunning == 1) {
              releaseID = responseGetReleaseIdJSON.data.id[0]
          } else {
              // if Application name is define in multiple release :
              // Retrieve only the Release Id linked to the correct Application version in the content of the correct release
              steps.echo("numberOfReleasesRunning :"+numberOfReleasesRunning)
              for (int i = 0; i < numberOfReleasesRunning; i++) {
                  releaseID = responseGetReleaseIdJSON.data.id[i]
                  steps.echo("i: "+i+", releaseID :"+releaseID)
                  steps.echo("i: "+i+", applicationId :"+applicationId)
                  def responseApplicationVersion = steps.httpRequest acceptType: 'APPLICATION_JSON',
                          consoleLogResponseBody: true,
                          authentication: 'CDD',
                          responseHandle: 'NONE',
                          url: "${BASE_URL}${CDD_RELEASES_ENDPOINT}/${releaseID}/applications/${applicationId}/application-versions"
                  def responseGetApplicationVersionJSON = new JsonSlurper().parseText(responseApplicationVersion.getContent())
                  def appVersion = responseGetApplicationVersionJSON.data.name
                  if (appVersion == applicationVersion) {
                      break
                  }
              }
          }
          steps.echo("CDD Release Id selected for the deployment :" + releaseID)
          return releaseID
      }
      

      Then the pipeline exit with no log or stacktrace available

      // Jenkins console log
      [Pipeline] httpRequest
      HttpMethod: GET
      URL: http://cde.axa.be/cdd/design/0000/v1/releases?status=DESIGN&status=RUNNING&status=RUNNING_WITH_ERRORS&application=558
      Accept: application/json
      Using authentication: CDD
      Sending request to url: http://cde.axa.be/cdd/design/0000/v1/releases?status=DESIGN&status=RUNNING&status=RUNNING_WITH_ERRORS&application=558
      Response Code: HTTP/1.1 200 
      Response: 
      {"pageNumber":0,"totalResultsCount":2,"pageSize":10,"data":[{"executionData":{"allowedStatuses":[],"releaseId":660,"status":"DESIGN","revision":3,"id":660,"className":"ReleaseExecutionDto"},"applications":[{"deletable":true,"sourceName":"Local","name":"be.axa.toolinghub.bsail003.etl-zip","id":558,"className":"ApplicationDto"}],"applicationVersions":[],"creationDate":1510756806000,"ownerParties":[{"email":"lesly.bernaola.external@axa.be","notificationEnabled":true,"firstName":"Lesly","lastName":"Bernaola","superUser":false,"role":"SYSTEM_ADMINISTRATOR","name":"lesly.bernaola.external@axa.be","id":22,"className":"UserDto"}],"version":"DM100002","description":"","name":"ETL On boarding 2","id":660,"className":"ReleaseDto"},{"executionData":{"allowedStatuses":["DONE"],"releaseId":654,"status":"RUNNING","revision":6,"id":654,"className":"ReleaseExecutionDto"},"applications":[{"deletable":true,"sourceName":"Local","name":"be.axa.toolinghub.bsail003.etl-zip","id":558,"className":"ApplicationDto"}],"applicationVersions":[],"creationDate":1510653395000,"startDate":1510656859000,"ownerParties":[{"email":"lesly.bernaola.external@axa.be","notificationEnabled":true,"firstName":"Lesly","lastName":"Bernaola","superUser":false,"role":"SYSTEM_ADMINISTRATOR","name":"lesly.bernaola.external@axa.be","id":22,"className":"UserDto"}],"version":"DM100001","description":"","name":"ETL On boarding","id":654,"className":"ReleaseDto"}]}
      Success code from [100‥399]
      [Pipeline] echo
      numberOfReleasesRunning :2
      [Pipeline] echo
      i: 0, releaseID :660
      [Pipeline] echo
      i: 0, applicationId :558
      [Pipeline] httpRequest
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // node
      

      Please note that same or other HTTP call work in other stages running in same node and same pipeline execution.

      Kr,

      Tarik.

        Attachments

          Activity

          Hide
          tarik_djebien Tarik Djebien added a comment -

          FYI,

           

          I tried to add a logger to retrieve more info on http request/response activities but it does not works :

          Show
          tarik_djebien Tarik Djebien added a comment - FYI,   I tried to add a logger to retrieve more info on http request/response activities but it does not works :
          Hide
          tarik_djebien Tarik Djebien added a comment -

          In https://github.com/jenkinsci/http-request-plugin/blob/master/src/main/java/jenkins/plugins/http_request/util/HttpClientUtil.java:

          public HttpResponse execute(HttpClient client, HttpContext context, HttpRequestBase method,
          PrintStream logger) throws IOException, InterruptedException {
          logger.println("Sending request to url: " + method.getURI());
          final HttpResponse httpResponse = client.execute(method, context);
          logger.println("Response Code: " + httpResponse.getStatusLine());
          return httpResponse;
          }
          

          We should see logs before the request is sent by Apache HTTP client but in this case even the line "Sending request to url: " did not appear in jenkins console log execution

          Show
          tarik_djebien Tarik Djebien added a comment - In https://github.com/jenkinsci/http-request-plugin/blob/master/src/main/java/jenkins/plugins/http_request/util/HttpClientUtil.java: public HttpResponse execute(HttpClient client, HttpContext context, HttpRequestBase method, PrintStream logger) throws IOException, InterruptedException { logger.println( "Sending request to url: " + method.getURI()); final HttpResponse httpResponse = client.execute(method, context); logger.println( "Response Code: " + httpResponse.getStatusLine()); return httpResponse; } We should see logs before the request is sent by Apache HTTP client but in this case even the line "Sending request to url: " did not appear in jenkins console log execution
          Hide
          tarik_djebien Tarik Djebien added a comment -

          Janario Oliveira,

          FYI, issue was resolved by Cloudbees support :

          JsonSlurperClassic should be used instead of JsonSlurper object instance.

          This resolve the HTTP call for this case.

          Kr,

          Tarik Djebien

          Show
          tarik_djebien Tarik Djebien added a comment - Janario Oliveira , FYI, issue was resolved by Cloudbees support : JsonSlurperClassic should be used instead of JsonSlurper object instance. This resolve the HTTP call for this case. Kr, Tarik Djebien
          Hide
          tarik_djebien Tarik Djebien added a comment -

          Cloudbees support answer:

          Is because the usage of JsonSlurper().. Use JsonSlurperClassic instead if you really need it but we are advising against any Slurper in Pipeline.

          Show
          tarik_djebien Tarik Djebien added a comment - Cloudbees support answer: Is because the usage of  JsonSlurper(). . Use  JsonSlurperClassic  instead if you really need it but we are advising against any  Slurper  in Pipeline.

            People

            Assignee:
            tarik_djebien Tarik Djebien
            Reporter:
            tarik_djebien Tarik Djebien
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: