NULL or BLANK option question

484 views
Skip to first unread message

Marco Favero

unread,
Apr 12, 2019, 8:04:18 AM4/12/19
to rundeck-discuss
Hello,

 I'm new in Rundeck, I would like to use it to expose some scripts, I found it fantastic!

My question is about how to pass the options to script, to allow execution by web interface.

Let suppose Linux OS. I have a script, such as

 /bin/myapp

with various options:

 /bin/myapp -h -par <value1> -par2 <value2> -n

Some options require a value, some options don't require a value.

First choice is to let only one rundeck option value and people type free text, but I would like a better interface, with a rundeck option value for each script option.
So my rundeck configured command could be

     /bin/myapp  ${option.-h} ${option.-par} ${option.-par2} ${option.-n}

but I can't understand how to manage options configuration.

For option with value it could be very useful a *prefix value* configurable, such as

"-par" for "value1"; or the option name as a prefix, if I call "-par" the name for the option value "value1".

Instead, I have to manage the value with a regular expression like

^\-par\s.+$

and I force user to type "-par" in the value.


But the main problems are script options with no value.
"-h" or "-n" in my example are script options with no value and not mandatory. So the rundeck option value could be a list with

"-h,"

with restriction enforced from allowed values, but empty value is not accepted.

I would like to know how do you deal with these problems, maybe there are some best practices.

I thank you very much for every help you could give me to understand.

Warm Regards
Marco

rac...@rundeck.com

unread,
Apr 12, 2019, 9:30:36 AM4/12/19
to rundeck-discuss
Hi Marco,

You can use in your command step: /path/to/my/script -m ${option.myoption} of course you need define your options in your job.

Hope it helps!

Marco Favero

unread,
Apr 12, 2019, 9:44:08 AM4/12/19
to rundeck-discuss
Hello,

 thank you for this tip, unfortunately this does not address these problems:

  • if "-m" is optional I can't remove it at all, because "-m" has been written in the command itself.
  • It is not yet a solution for an option not mandatory with no value
About first point, of course I can modify the script to manage "-m" with no value, but this is not always possible.

Thank you
Marco

rac...@rundeck.com

unread,
Apr 12, 2019, 9:51:26 AM4/12/19
to rundeck-discuss
Hi Marco,

Then a good option is using cascade options for your parameters, take a look to this example:


And the documentation:


Regards!

Marco Favero

unread,
Apr 16, 2019, 9:55:11 AM4/16/19
to rundeck-discuss
Hello,

 thank you! Cascading and remote options are useful anyway, I'll often adopt them.

I found useful this inline script


to manage options with value in a single job.
Options with null or empty values are not allowed at all, but I created the value " " to obtain the same result as "".

Thank you
Marco
Reply all
Reply to author
Forward
0 new messages