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

Handle file parameters

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      JENKINS-27295 discusses getting values from various kinds of parameters. Handling FileParameterValue is another matter. buildEnvironment (what is called today) is useless since it gives only a file name. createBuildWrapper is the way this works in a freestyle project, but this cannot work in a workflow; even if it were to return a SimpleBuildWrapper (JENKINS-24673) it is not clear where that would be called, since we can only use it from a workspace. getValue as currently implemented is useless since a FileItem does not have whitelisted methods, and anyway we would not want the flow itself to be copying streams to the workspace; this needs to be done by infrastructure. The only way forward I can see at the moment is for getValue to return a SimpleBuildWrapper, so that your flow could read

      node {
        wrap([$delegate: parameters.myFileParam]) {
          sh 'cat myFileParam'
        }
      }
      

        Attachments

          Issue Links

            Activity

            Hide
            kozchris Chris Snyder added a comment -

            Took a while to find out that this was an issue. Plus one for getting this fixed in an upcoming release. 

            UnstashParam worked for me. Thanks.

            Show
            kozchris Chris Snyder added a comment - Took a while to find out that this was an issue. Plus one for getting this fixed in an upcoming release.  UnstashParam worked for me. Thanks.
            Hide
            emman27 Emmanuel Goh added a comment - - edited

            Can confirm that this is still broken - my minimal Jenkinsfile below yields "echo null":

             

            pipeline {
              agent any
              parameters {
                file(name: 'ZIP')
              }
              stages {
                stage('Test file') {
                  steps { 
                    sh "echo ${params.ZIP}" 
                  }
                }
              }
            }
            
            Show
            emman27 Emmanuel Goh added a comment - - edited Can confirm that this is still broken - my minimal Jenkinsfile below yields "echo null":   pipeline { agent any   parameters {     file(name: 'ZIP' )   }   stages {     stage( 'Test file' ) { steps { sh "echo ${params.ZIP}" } } } }
            Hide
            baukaman Bauyrzhan Makhambetov added a comment -

             works in freesyle project but in pipeline is not working.

             
            tried with `ls -l .` with no success, as if there is no file at all.

            Show
            baukaman Bauyrzhan Makhambetov added a comment -  works in freesyle project but in pipeline is not working.   tried with `ls -l .` with no success, as if there is no file at all.
            Hide
            jglick Jesse Glick added a comment -

            File parameters are not currently supported. I am not particularly inclined to fix this per se since support for them is quite complicated architecturally—the implementation for freestyle projects does not generalize naturally and relies on a special file upload web request handler. Simpler, safer, and more flexible would be to introduce a plugin defining a Base64-encoded string parameter type, with a form submission GUI and CLI that make it convenient to obtain the value from a local file, as well as a SimpleBuildWrapper (usable as a Pipeline block-scoped step) that decodes the value to a local temporary file within its body.

            Show
            jglick Jesse Glick added a comment - File parameters are not currently supported. I am not particularly inclined to fix this per se since support for them is quite complicated architecturally—the implementation for freestyle projects does not generalize naturally and relies on a special file upload web request handler. Simpler, safer, and more flexible would be to introduce a plugin defining a Base64-encoded string parameter type, with a form submission GUI and CLI that make it convenient to obtain the value from a local file, as well as a SimpleBuildWrapper (usable as a Pipeline block-scoped step) that decodes the value to a local temporary file within its body.
            Hide
            baukaman Bauyrzhan Makhambetov added a comment -

            Thank you for pointing that out.

            Show
            baukaman Bauyrzhan Makhambetov added a comment - Thank you for pointing that out.

              People

              • Assignee:
                Unassigned
                Reporter:
                jglick Jesse Glick
              • Votes:
                87 Vote for this issue
                Watchers:
                94 Start watching this issue

                Dates

                • Created:
                  Updated: