Details
-
Improvement
-
Status: Resolved (View Workflow)
-
Minor
-
Resolution: Fixed
-
None
-
-
workflow-cps-global-lib 2.10, workflow-basic-steps 2.8.1, workflow-basic-steps 2.10
Description
Trying to store png file in resources (project logo, common for all pipelines using shared library) and deploy it from there using:
writeFile file: "logo-96x96.png", text: libraryResource("logo-96x96.png")
but the file is no longer readable after this operation.
Is there additional parameter I could use (libraryResource has no documented parameters) or is there other suitable way of achieving this functionality?
It looks like libraryResource reads the contents of the file into a String using the default system encoding, and writeFile encodes the given text using the system default encoding if no other encoding is specified, so doing this with binary files totally mangles the data. It doesn't look like there are any options that would make those steps work for your use case.
The best workarounds that I can think of are if the image is available at some static URL that Jenkins has access to you could download and write it to the desired location in a shell step using curl/wget, or if the image is in the repo itself you could use a shell step to copy it as desired.