Jenkins How can i upload a text file and use it as a parameter

12,134

You can upload a file from your computer to the workspace through the File parameter of the job.

You can use Extended Choice plugin parameter, to read value(s) from a file and display them in a dropdown/radio-button/checkbox for the user to select, dynamically, every time the build is triggered.

You can use EnvInject plugin to read value(s) from a file and inject them into the build as environment variables, so that they can be used by the rest of the build steps/scripts.

Your question is very unclear on what your are trying to do. Pick one of the 3 methods above based on what you need, or clarify your question.

Share:
12,134
Alex Brodov
Author by

Alex Brodov

Updated on June 05, 2022

Comments

  • Alex Brodov
    Alex Brodov almost 2 years

    I have a txt file that is holding a string inside, I want to be able to use this string in one of my scripts, so I'm wondering if there is a way to set the content of the file as one of the build properties or parameters which I'll be able to use in my scripts it should be the same as using one of the build environment properties. For example : ${JOB_NAME} which is holding the the job name, so in the same way I want to access the content of the file which is holding some value inside. Is it possible?

  • Slav
    Slav over 9 years
    Use the EnvInject plugin for that. As long as your file stores the value as param=value, you can provide that file to EnvInject plugin step, and your value will be available to the rest of your job as $param (or %param% if on Windows)
  • Alex Brodov
    Alex Brodov over 9 years
    The thing is that my file stores just a string and not param=value, is it still possible somehow to pass it? If not i can try to cat the string from this file and put into a new file, or i can put into a new variable which will be done by bash script
  • Slav
    Slav over 9 years
    You are going to have to format it in param=value style for EnvInject plugin.
  • Alexey Strakh
    Alexey Strakh over 9 years
    I have similar task and this file has a free text format. I'm ok to add SOME_KEY_NAME= in the beginning of the file. But it is multiline file and I'm not ok to put (ask everybody else) the '/' in the end of each line. Any ideas how to have this parameter to be multiline without extra efforts?
  • Slav
    Slav over 9 years
    @AlexeyStrakh sorry, haven't used it that much to have an answer for you