Nested substitution


#1

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!


#2

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.


#3

What would that look like for example starting with:

FOO=BaR@Baz.com

Wanting to strip off @Baz.com and lowercase BaR?

Started with this (which works):
${DRONE_COMMIT_AUTHOR_EMAIL%%@Baz.com}

Tried things like:
${foo=${DRONE_COMMIT_AUTHOR_EMAIL%%@Baz.com},,}

Any ideas?


#5

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:

${DRONE_COMMIT_AUTHOR_EMAIL,,}

But this will not work:

${${DRONE_COMMIT_AUTHOR_EMAIL},,}

-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=${DRONE_COMMIT_AUTHOR_EMAIL%%@Baz.com},,}

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.


#6

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

any solution ?