最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Rundeck : Mixing cascading options with OptionValues plugin - Stack Overflow

programmeradmin3浏览0评论

I created a very simple Rundeck OptionValues plugin. just to see how it works. Basically I have the plugin run a script that sets 3 variables, x,y and z to a random word from a list of words in a file.

x=`cat /home/rundeck/words | xargs shuf -n1 -e`
y=`cat /home/rundeck/words | xargs shuf -n1 -e`
z=`cat /home/rundeck/words | xargs shuf -n1 -e`

RESULTS=("$x" "$y" "$z")
    echo "==START_OPTIONS=="
    for result in "${RESULTS[@]}"; do
        echo "$result:$result"  # Using value:label format
    done
    echo "==END_OPTIONS=="

And this creates a drop down for an option, (let's call it ${option.word}) in the Rundeck job of these 3 random words (example sublime, subside, succumb) and they change every time the job page is loaded.

This is not much use, but it shows me how I can run a script on the fly to generate the values in a drop down.

So my next goal is, use values from other options, in the script, to generate the ${option.word} values.

In cascading options, the value of an option can be retrieved by pointing to a Remote URL, a JSON file, like this:

file:/home/rundeck/${option.ClientCode.value}.json

And that changes depending on the value of ${option.ClientCode}.

How can I pass ${option.ClientCode} to the script in the plugin, such that I can do something like:

x="$x-${option.ClientCode.value}
y="$y-${option.ClientCode.value}
z="$z-${option.ClientCode.value}

 RESULTS=("$x" "$y" "$z")

So with client code set to say, DEF003, instead of the dropdown being:

sublime
subside
succumb

my dropdown would now by

sublime-DEF003
subside-DEF003
succumb-DEF003
发布评论

评论列表(0)

  1. 暂无评论