Nested substitution

I’m using Drone 0.7.3. I’m trying to do nested substitution, but it seems I haven’t found a working syntax. Is it supported? If not, will it be? Thanks!

Yes nested parameters are supported. We have an examples in our unit tests:

If you are creating a complex substitution string, I recommend crafting it from your bash terminal. We often see people trying to use bad substitution strings that would fail in bash, which therefore fail when used with the drone bash substitution emulator.

If you have a substitution string that works in bash, and it is not working in drone, you can post here and I can take a look.

What would that look like for example starting with:

Wanting to strip off and lowercase BaR?

Started with this (which works):

Tried things like:

Any ideas?

Unfortunately I do not think this will work. Bash will not accept a substitution expression where the left side of the expression is not an environment variable.

For example this will work:


But this will not work:


-bash: ${${DRONE_COMMIT_AUTHOR_EMAIL},,}: bad substitution

This syntax will not produce an error in bash, but will not convert to lowercase (on ubuntu 14)

echo ${AUTHOR=${},,}

So unfortunately I am not aware of a supported syntax to achieve this. I am happy to try to advise a workaround, if you can provide a bit more detail on what you would like to achieve.

hi, need the same
my DRONE_COMMIT_BRANCH=feature/XP-9999
I need create lowercase docker tag: “xp-9999”

any solution ?

1 Like

Parse a Kubernetes namespace compatible string out of Drone variable DRONE_COMMIT_REF.
refs/tags/v1.0.23 => v1-0-23
Allow variable substitution were one is based on the other: