Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use defaults for optional parameter values, and expand to blank value when missing #352

Closed
andysteady opened this issue Apr 9, 2013 · 5 comments

Comments

@andysteady
Copy link

Parameters that are optional, are not having their values passed through to bash, command.

Tested on 1.5GA and 1.5.1 snapshot 209.

This one is problematic.

@gschueler
Copy link
Member

If you are expecting defaulting behavior for options, then you have to set the default value for the option and mark it as "Required". If it is not required (optional), then Rundeck won't automatically include the defaulted value for it.

@andysteady
Copy link
Author

Sorry I got confused on this one, the issue I was facing was that a non-optional parameter, with no default, cannot be referenced in the command line. I guess thats obvious because it doesn't exist but I was hoping for a no value to be passed so I could test via -z in my script. What I actually get is an invalid substitution error.

So if there is an optional parameter with no default, it means you can't pass it to a script - you need to test for it somehow in the command line arguments for the script.

I have now got a work around for it:

  • set the default to be a single space and make the option required
  • In the command line args to the script with speech marks: "${option.target}"
  • In the script: TARGET=echo "$1" |tr -d ' '

@gschueler
Copy link
Member

You can try using the other sytanxes:

  • $RD_OPTION_TARGET using environment variables, should evaluate to empty string in shell context if it isn't set
  • @option.target@ in an inline script: will be replaced by Rundeck with the value, or not replaced if it doesn't exist.

@gschueler
Copy link
Member

some discussion on the mailing list: https://groups.google.com/forum/?fromgroups=#!topic/rundeck-discuss/-Wj9dUQxUAM

gschueler added a commit that referenced this issue Jul 2, 2013
@ahonor
Copy link
Contributor

ahonor commented Jul 25, 2013

Verified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants