Get User Input For Scripts

102 views
Skip to first unread message

Martin Dalin

unread,
Nov 7, 2022, 7:51:38 AM11/7/22
to rundeck-discuss
Hello,

Is there a way in Rundeck to get user input for shell scripts?

I tried this, but the user is not prompted for input:
#!/bin/bash

echo "argument one is: $1"
read -p "enter something " myvar
echo $myvar

exit 0

I also tried "job options", and you get an input field before executing the job.
But I don't know how to get the value of the option.

I used an option with the name "your_name" but the variables I try to get the entered value from are empty:

#!/bin/bash

echo $RD_OPTION_YOUR_NAME
myoption="${option.your_name}"
echo "your path is ${myoption}"

exit 0

Regards Martin

rac...@rundeck.com

unread,
Nov 7, 2022, 8:05:50 AM11/7/22
to rundeck-discuss

Hi Martin,

That’s the way how Rundeck works, if you want to put user data on Rundeck, just create an option and then execute the job.

To get the info from jobs create the option and use it in the ${option.myoption} format for command step, @option.myoption@ or $RD_OPTION_MYOPTION for “external scripts”.

Here is an example. You can import it to your test instance and see how it works.

- defaultTab: nodes
  description: ''
  executionEnabled: true
  id: 4743033d-5246-479b-aa22-3e7122aa2868
  loglevel: INFO
  name: MyOption
  nodeFilterEditable: false
  options:
  - name: input
    value: world
  plugins:
    ExecutionLifecycle: null
  scheduleEnabled: true
  sequence:
    commands:
    - script: echo "hello @option.input@"
    keepgoing: false
    strategy: node-first
  uuid: 4743033d-5246-479b-aa22-3e7122aa2868

Hope it helps!

Reply all
Reply to author
Forward
0 new messages