How to use Jenkins parameters in a shell script How to use Jenkins parameters in a shell script jenkins jenkins

How to use Jenkins parameters in a shell script


What really helped me was Hudson: How to pass parameters to shell script

Solution: the variables are UPPERCASE even you define them in lowercase!


Jenkins will create environment variables with the parameters' names.

The caveat here is that Jenkins will also do that for parameters that do not represent valid variable names -- those are difficult to access in bash. This is the case in your example, as bash variable names must not contain the . character.

The easiest solution is that you

  • rename your parameters, e.g. to high_version and low_version (which are valid bash variable names)
  • then use the corresponding variable names when calling your script

Example:

/bin/bash /hai/mycode/scripts/run_script.sh "$high_version"

If you cannot rename parameters to represent valid bash variable names (e.g., for usability reasons: Jenkins presents variable names to end users in the Web form for starting a build): you can still access such parameters by grepping for the parameter name in the output of the env command.


Use following syntax to pass jenkins parameter to shell script -

eg. YourScript.sh %JENKINS_PARAMETER%after that in your script,you can use that parameter like normal shell script command line parameter.eg. myParam = $1;