Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of a stashedFile parameter in a build step #126

Open
RobinFauvel opened this issue Aug 26, 2022 · 5 comments
Open

Use of a stashedFile parameter in a build step #126

RobinFauvel opened this issue Aug 26, 2022 · 5 comments
Labels
documentation Improvements or additions to documentation

Comments

@RobinFauvel
Copy link

Describe your use-case which is not covered by existing documentation.

The documentation clearly indicates how to pass a base64File parameter to a downstream Job via the build step.
This is not the case for a parameter of type stashedFile. In particular, how to create a file of type org.apache.commons.fileupload.FileItem to give to the file argument?
Thank you

Reference any relevant documentation, other materials or issues/pull requests that can be used for inspiration.

No response

@RobinFauvel RobinFauvel added the documentation Improvements or additions to documentation label Aug 26, 2022
@jglick
Copy link
Member

jglick commented Oct 4, 2022

I do not think there should be any difference. base64File and stashedFile would differ only in how the downstream build stores the parameter, not how it accepts it.

@jamesvanhorn
Copy link

jamesvanhorn commented Mar 3, 2023

Is there any update here? I am facing the same issue. I have a job that takes a stashedFile and a string as parameters, but I can't figure out how to call that from an upstream pipeline?

File build = runSomeOtherMethod();
build job: 'build-server-apk', parameters: [
                            stashedFile(name: 'FILE', base64: Base64.encoder.encodeToString(build.bytes)),
                            string(name: 'BUILD_CONFIG', value: "${buildConfig}")
                    ]

This results in an error like...

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.io.File.call() is applicable for argument types: (java.util.LinkedHashMap) values:  [[job:build-server-apk, parameters:[@stashedFile(name=FILE,value=/jenkins_data/jenkins_home/jobs/TWC Flagship App/jobs/Apps-Upload-Build-To-BrowserStack-With-Espresso/workspace/sdui-main-104.apk), ...]]]
Possible solutions: wait(), any(), wait(long), any(groovy.lang.Closure), each(groovy.lang.Closure), list()

To be clear this is a larger file, hence the use of a stashed file. about 150MB

Edit: that output was actually from a second run passing the java.nio.File object directly. Encoding to Base64 string did not work either for reference.

@jglick
Copy link
Member

jglick commented Mar 3, 2023

Is there any update here?

Sorry, no, I have not found time to write a test for this scenario and investigate.

this is a larger file, hence the use of a stashed file. about 150MB

FYI performance is likely to be poor if you are trying to pass around large files between builds using the build step. https://github.com/jenkinsci/file-parameters-plugin#usage-with-build is intended for small files only (for which stashing would be overkill anyway). Efficiently transferring large files would require a more complicated design TBD. It is best to handle large files using an external artifact repository or blob store and have Jenkins just pass around URLs or other handles, though I suppose if you had such a system configured and available you would not need this plugin to begin with!

@jamesvanhorn
Copy link

Thank you, appreciate the response. Yeah I wish I had an artifact repo setup for this haha. Though your phrasing does give me an alternative idea that may be workable. We do a fetch on the file in the parent pipeline. My thought was to pass the file along, but that's how I ended up here....

It's not ideal, but I could just pass the name of the file into the child job and rerun the fetch a second time. Not the end of the world I suppose.

@jglick
Copy link
Member

jglick commented Mar 3, 2023

If you can fetch the file from somewhere else, that is probably better, as it reduces the disk consumption and I/O pressure on the Jenkins controller (assuming you run builds on agents). Stashed file parameters are more intended for cases where largish files must be submitted to the controller, whether through a browser upload by a human, or REST or CLI action from some external tool, and would not easily be available for download.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants