Drop down variables listed by bash output

I am sure I am not the first guy who needed define docker image tag during Helm chart deployment in Octopus world.

I would like to define a variable as “drop down menu” but the content of drop down options must be created as a result of bash sentence; something like that:

(it doesn’t work of course, that’s why I need to help.)

…or another way to accomplish same purpose which pulls the ECR docker images (I have ECR feed defiend in Octopus) and plug them as drop-down variable in “Helm Chart Upgrade” template.

Could you please advise?

Thanks & Regards

Hey @tirelibirefe , thanks for reaching out!

Dynamic drop down values are definitely something that comes up in different deployment contexts. Generally, the way we’d recommend approaching it is creating a runbook that can call out for the needed values and then perform an API call to your Octopus instance to update the prompted variable values for your deployment process.

While we don’t have a great native Bash example of a script like this, but you can see a PowerShell/C#/Python/Golang example in our documentation here.

The biggest difference you’ll find is that prompted variables have a slightly different object shape - here’s an example from a local variable in my instance:

    "Id": "eabd2d60-286f-6f7f-3449-66f22891032d",
    "Name": "DropDown",
    "Value": "First Service",
    "Description": null,
    "Scope": {},
    "IsEditable": true,
    "Prompt": {
        "Label": "ServiceSelector",
        "Description": "Select the relevant service",
        "Required": true,
        "DisplaySettings": {
            "Octopus.ControlType": "Select",
            "Octopus.SelectOptions": "service-1|First Service\nservice-2|Second Service\nservice-3|Third Service"
    "Type": "String",
    "IsSensitive": false

In the above object, Value is the default value for the drop down (optional). The important changes are under the Prompt object, where you’ll see matches for the UI elements in your screenshot. The Prompt.DisplaySettings[Octopus.ControlType] will be Select for drop down lists, and the Prompt.DisplaySettings[Octopus.SelectOptions] will be your drop down items, formatted as Value1|Display text 1\nValue2|Display text 2. The newline characters (\n) will be appropriately interpereted when it’s in the Octopus UI.

Put all together, a process like:

  • ECR command to get the image list
  • Format into value|display string
  • Modify variable set via API call to update the values

Should work as a scheduled runbook to keep your drop down values in sync. Please let me know if you have any questions or concerns, happy to help!

Hello @cory.reid
Thanks for your answer and help.
Where should I enter this code?

Thanks & Regards

the following aws cli command (bash) pulls the list from ECR.

aws ecr list-images --repository-name "docker/myimage" |\
  jq --raw-output '.imageIds | map (.imageTag)|sort|.[]'  | sort -r

Can I use this one instead of yours?

Does your json work on Ubuntu?

Thanks & Regards

Sorry, the documentation doesn’t define where to enter the code…

Thanks & Regards

here is the solution:

I added package reference as described here.

Assigned its variable to “Upgrade Options / Additional Arguments” as Helm parameter.

That’s all.

The simplest approach!

I’m glad you got it working!

My original suggestion was reliant on executing a script against the Octopus API to update the values, yours is likely much simpler using your existing data. Happy you have something workable, feel free to reach out if you run into any other questions or challenges!

@cory.reid I think it doesn’t work. :disappointed_relieved:
currently I have another issue here; so I am not able to test it end-to-end but logs say that:

Package 'mydockerimagename' was not acquired or does not require staging Using Release Name mynamespace

Do you have any idea why my package wasn’t required? Or is there anything wrong with namespace?

It was my first question. My second question is that if go to beginning, what is function/purpose of “bash script” in script editor page if it doesn’t get/run to create variables?

Thanks again…

If this was a second deployment attempt, your package may not have been acquired because it was already cached on the worker, so I don’t think there’s anything to worry about there unless it’s unable to sue your package. The error you’re seeing is a cluster specific error, shouldn’t be related to any individual package.

As far as the editor page, that’s for variable edits, and the language selector provides syntax highlighting, rather than an execution environment for those script types. For creating variables based on dynamic scripts, Octopus offers the ability to create output variables via custom scripts/package steps. Similar to the discussion above, if you wanted to set a variable’s possible drop down values based on the results of a script execution, you’d need a step in the process to call the Octopus API and update the variables for the relevant project.

@cory.reid thanks for the explanation. This is definitely useful for me when I need it.
Also, we close this ticket; as you said, there is nothing to worry about package was not acquired warning.
Things work on Windows how I explained above.

Thanks for your all your support and advises.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.