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

Allow writing response to file in pipeline

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Currently the http request plugin supports writing response content to file in freeflow jobs, but not in pipeline jobs.

      The advised way is:

      def response = httpRequest "http://httpbin.org/response-headers?param1=${param1}"
      node() {
          writeFile file: 'response.txt', text: response.content
      }

      But writeFile currently ignores encoding. (https://issues.jenkins-ci.org/browse/JENKINS-27094)
      This makes writing binary files (e.g. those retrieved using https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-RetrieveLatestArtifact) difficult. That is they can be written using wrong encoding.

        Attachments

          Issue Links

            Activity

            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Janario Oliveira
            Path:
            src/main/java/jenkins/plugins/http_request/HttpRequestExecution.java
            src/main/java/jenkins/plugins/http_request/HttpRequestStep.java
            src/main/resources/jenkins/plugins/http_request/HttpRequestStep/config.jelly
            http://jenkins-ci.org/commit/http-request-plugin/434ce55d34e5b67a43a5bf887047c19a977085a8
            Log:
            JENKINS-37627 Added outputfile to pipeline

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Janario Oliveira Path: src/main/java/jenkins/plugins/http_request/HttpRequestExecution.java src/main/java/jenkins/plugins/http_request/HttpRequestStep.java src/main/resources/jenkins/plugins/http_request/HttpRequestStep/config.jelly http://jenkins-ci.org/commit/http-request-plugin/434ce55d34e5b67a43a5bf887047c19a977085a8 Log: JENKINS-37627 Added outputfile to pipeline
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Janario Oliveira
            Path:
            src/main/java/jenkins/plugins/http_request/HttpRequestExecution.java
            src/main/java/jenkins/plugins/http_request/HttpRequestStep.java
            src/main/java/jenkins/plugins/http_request/ResponseContentSupplier.java
            src/main/java/jenkins/plugins/http_request/ResponseHandle.java
            src/main/resources/jenkins/plugins/http_request/HttpRequestStep/config.jelly
            src/main/webapp/help-responseHandle.html
            src/test/java/jenkins/plugins/http_request/HttpRequestTest.java
            http://jenkins-ci.org/commit/http-request-plugin/038edbe137d4213e9b0f7e0165c279b694ebce90
            Log:
            JENKINS-37627 - Improved saveToFile to avoid convertion of string. Added ResponseHandle to better control how reponse should be handled.

            Compare: https://github.com/jenkinsci/http-request-plugin/compare/d9e43928e36d...038edbe137d4

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Janario Oliveira Path: src/main/java/jenkins/plugins/http_request/HttpRequestExecution.java src/main/java/jenkins/plugins/http_request/HttpRequestStep.java src/main/java/jenkins/plugins/http_request/ResponseContentSupplier.java src/main/java/jenkins/plugins/http_request/ResponseHandle.java src/main/resources/jenkins/plugins/http_request/HttpRequestStep/config.jelly src/main/webapp/help-responseHandle.html src/test/java/jenkins/plugins/http_request/HttpRequestTest.java http://jenkins-ci.org/commit/http-request-plugin/038edbe137d4213e9b0f7e0165c279b694ebce90 Log: JENKINS-37627 - Improved saveToFile to avoid convertion of string. Added ResponseHandle to better control how reponse should be handled. Compare: https://github.com/jenkinsci/http-request-plugin/compare/d9e43928e36d...038edbe137d4
            Hide
            janario Janario Oliveira added a comment -

            Added parameter outputFile to write content to file.

            For large files it would be better to use responseHandle: 'NONE' together.

             

            node() {

            httpRequest url: 'url', responseHandle: 'NONE', outputFile: 'output.jar'

            }

             

            Show
            janario Janario Oliveira added a comment - Added parameter outputFile to write content to file. For large files it would be better to use responseHandle: 'NONE' together.   node() { httpRequest url: 'url', responseHandle: 'NONE', outputFile: 'output.jar' }  

              People

              Assignee:
              janario Janario Oliveira
              Reporter:
              pisu Grzegorz Pisarek
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: