2
votes

I have created an Oozie workflow that uses the script action. The script that it calls has two mandatory parameters and several optional parameters. What is the correct way to handle optional parameters in an Oozie workflow?

oozie job -config job.properties -run -DMandatory1 a -DMandatory2 b -DOptional1 c

I can not list the parameters in the workflow XML (Optional2, Optional3,ect) because Oozie will error out stating that the parameter does not exist. Do I need create multiple workflows and create some logic prior to calling the Oozie script that would allow for each option?

2

2 Answers

0
votes

Did you try to pass empty strings as parameters value, e.g. -Doptional1 '' on the command line?

If the shell script is smart enough to ignore empty parameters (e.g. $# -ge 3 but "$3" == "" means "no parameter 3") then the result will be the same as not passing the parameter.

0
votes

If the number of parameters are less then you can go for the pass some default dummy value for the optional variable. Then you can check for the same in your shell script. If the default value comes then don't use it or else use it.

Because if you do not specify any variable mentioned inn your shell or ssh action in workflow, Oozie will fail giving an EL Error as it will not be able to replace the optional variable with anything.