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
            jglick Jesse Glick added a comment -

            I have released an initial version of the File Parameter plugin. I think it covers the basic use cases for Pipeline users. Use its issue tracker as needed.

            Show
            jglick Jesse Glick added a comment - I have released an initial version of the File Parameter plugin. I think it covers the basic use cases for Pipeline users. Use its issue tracker as needed.
            Hide
            navrkald David Navrkal added a comment - - edited

            Hello Jesse Glick, first of all, thx for implementing new plugin! Is there any change your File Parameter plugin will get promoted to the Cloudbees Update Center where are verified and trusted opensource plugins since it is currently only working workaround for broken file parameter?

            As well I guess if this issue was closed with resolution people should use new File Parameter plugin then the original (for years broken and still not working) file parameter should be removed from Jenkins to prevent people confusion and stop waisting time on not existing workarounds...

            Show
            navrkald David Navrkal added a comment - - edited Hello Jesse Glick , first of all, thx for implementing new plugin! Is there any change your File Parameter plugin will get promoted to the Cloudbees Update Center where are verified and trusted opensource plugins since it is currently only working workaround for broken file parameter? As well I guess if this issue was closed with resolution people should use new  File Parameter plugin then the original (for years broken and still not working) file parameter should be removed from Jenkins to prevent people confusion and stop waisting time on not existing workarounds...
            Hide
            jglick Jesse Glick added a comment -

            Is there any change your File Parameter plugin will get promoted to the Cloudbees Update Center

            If you are a CloudBees customer, open an RFE via the normal process. I am not personally in charge of such decisions.

            the original […] file parameter should be removed from Jenkins [core]

            Well, I do not think we can remove it. In principle it could be detached to a (deprecated) plugin. Certainly we could consider adding help text and the like in core suggesting use of https://plugins.jenkins.io/file-parameters/ in its place, once it has gotten some more serious usage to shake out design problems.

            Show
            jglick Jesse Glick added a comment - Is there any change your File Parameter plugin will get promoted to the Cloudbees Update Center If you are a CloudBees customer, open an RFE via the normal process. I am not personally in charge of such decisions. the original […] file parameter should be removed from Jenkins [core] Well, I do not think we can remove it. In principle it could be detached to a (deprecated) plugin. Certainly we could consider adding help text and the like in core suggesting use of https://plugins.jenkins.io/file-parameters/ in its place, once it has gotten some more serious usage to shake out design problems.
            Hide
            reneb Rene Buergel added a comment - - edited

            Jesse Glick this is a cool plugin, thank you!

            how's the intended handling of non-mandatory large files used with stashedFile in declarative?

            • If no file is provided and the build is triggered manually, unstashing works, but the file is 0 Bytes.
              For stages depending on the file, I'm using the following (unfortunately platform-dependent) when-condition:
              when { expression { sh(returnStatus:true, script: '[ -s FPGA.zip ]' ) == 0 } }
              
            • If no file is provided and the build is triggered by the SCM, unstashing fails because the whole parameter seems to be missing, so I need to wrap the unstash into a catchError

            I think, that's a quite cumbersome error handling for basically the same case (no file provided)

            Show
            reneb Rene Buergel added a comment - - edited Jesse Glick this is a cool plugin, thank you! how's the intended handling of non-mandatory large files used with stashedFile in declarative? If no file is provided and the build is triggered manually, unstashing works, but the file is 0 Bytes. For stages depending on the file, I'm using the following (unfortunately platform-dependent) when-condition: when { expression { sh(returnStatus: true , script: '[ -s FPGA.zip ]' ) == 0 } } If no file is provided and the build is triggered by the SCM, unstashing fails because the whole parameter seems to be missing, so I need to wrap the unstash into a catchError I think, that's a quite cumbersome error handling for basically the same case (no file provided)
            Hide
            jglick Jesse Glick added a comment -

            Rene Buergel for any bugs or RFEs please use GitHub Issues, and be sure to provide a complete, self-contained, reproducible test case.

            Show
            jglick Jesse Glick added a comment - Rene Buergel for any bugs or RFEs please use GitHub Issues, and be sure to provide a complete, self-contained, reproducible test case.

              People

              Assignee:
              jglick Jesse Glick
              Reporter:
              jglick Jesse Glick
              Votes:
              111 Vote for this issue
              Watchers:
              119 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: