Inject variables not correctly evaluated

Issue #4 resolved
Mark de Bont created an issue

When using Bamboo's (5.10.0) "Inject Bamboo variables configuration" to inject variables from a property file I can not evaluate the variables correctly. However, they do not seem to correctly evaluate. It always evaluates to False.

simple 24-Feb-2016 09:16:22 GroovyShell bindings: simple 24-Feb-2016 09:16:22 groovyVariableName=Condition simple 24-Feb-2016 09:16:22 inject.FW_S2L=SL simple 24-Feb-2016 09:16:22 bambooDelimiterParsingDisabled_0=true

So I evaluate them. I would expect the example below to be True

24-Feb-2016 09:16:22 Groovy Shell starting 24-Feb-2016 09:16:22 Groovy script script: if ( 'inject.FW_S2L[1]' == 'SL' ) return 'True' else return 'False'; evaluated to [False] 24-Feb-2016 09:16:22 Disabling task [SKIPME] 24-Feb-2016 09:16:22 tasks list not set, skipping

And this one to be false

24-Feb-2016 09:16:22 Groovy Shell starting 24-Feb-2016 09:16:22 Groovy script script: if ( 'inject.FW_S2L[1]' == 'AA' ) return 'True' else return 'False'; evaluated to [False] 24-Feb-2016 09:16:22 Disabling task [SKIPME] 24-Feb-2016 09:16:22 tasks list not set, skipping

I have tried a lot of combinations, with ' and without etc. ;-(

Comments (7)

  1. Hutuleac Iulius repo owner

    According to the bindings the variable name is "inject.FW_S2L" so code should be:

    if ( inject.FW_S2L.equals("SL") ) return "True" else return "False";

    in order to evaluate to "True"

    If this does not work it means that "." is being interpreted by groovy as regular java so it would mean I have to convert any "." to lets say "_" as groovy will start looking for object inject with member FW_S2L.

    Can you try the line above, I can make a quick fix and release a new version with . to _ conversion

  2. Mark de Bont Account Deactivated reporter

    I've used the new string as you advised. But now it evaluates with a NULL.

    24-Feb-2016 11:15:46 GroovyShell bindings: 24-Feb-2016 11:15:46 groovyVariableName=Condition 24-Feb-2016 11:15:46 inject.FW_S2L=SL

    24-Feb-2016 11:12:25 Groovy Shell starting 24-Feb-2016 11:12:25 Groovy script if ( inject.FW_S2L.equals("SL") ) return "True" else return "False"; 01-Jan-1970 01:00:00 evaluated to [null] 24-Feb-2016 11:12:25 Disabling task [SKIPME]

    FYI: I use 'inject' as the namespace in the "Inject Bamboo variables configuration" step

  3. Hutuleac Iulius repo owner

    Compiled and uploaded a new release with a fix for the dots. I will upload now to marketplace also but there is going to take few hours until it becomes available, you can pick the jar directly from the releases in github and deploy it under addons in Bamboo

  4. Log in to comment