[OpenStack-Infra] [jjb] What's the deal with {{?

Darragh Bailey daragh.bailey at gmail.com
Thu Aug 13 10:19:33 UTC 2015


Hi,


macros do not get substitution performed unless you provide a variable to
be substituted in.


Following would trigger the behaviour:


- job-template:
    name: '{foo}-test'
    builders:
      - test_builder:
          FOO_BAR: hello
      - shell: |
          echo ${{FOO_3}}


Definitely a bit confusing, essentially the macro is added in through a
lookup in the register.ModuleRegistry.dispatch() method, where only if the
component is a dict is a substitution performed:
https://github.com/openstack-infra/jenkins-job-builder/blob/4a8b93b8c2d517c8dc27d91437454890cc49a640/jenkins_jobs/registry.py#L149-L168


I wonder if jinja templating would avoid some of the quirks we run into
around using python's string formatting for substitution?


On 13 August 2015 at 07:05, Ian Wienand <iwienand at redhat.com> wrote:

> Hi,
>
> Just trying to get my head around this from [1]:
>
> ---
>
> - builder:
>     name: test_builder
>     builders:
>       - shell: |
>            echo ${FOO_1}
>            echo ${{FOO_2}}
>
> - job-template:
>     name: '{foo}-test'
>     builders:
>       - test_builder
>       - shell: |
>            echo ${{FOO_3}}
>
> - project:
>     name: 'foo'
>     jobs:
>       - '{foo}-test':
>          foo: bar
>
> ---
>
> that's going to output a job basically
>
> ---
> echo ${FOO_1}
> echo ${{FOO_2}}
> echo ${FOO_3}
> ---
>
> Why do I *not* get a "FOO_1 parameter missing" for test_builder?  If I
> do
>
> ---
>
>       - test_builder:
>           FOO_1: bar
>
> ---
>
> it does actually come out with "echo $bar" as you might expect.
>
> Or the same question in reverse: why *do* I get an error about a
> missing parameter if I have just "${FOO_3}" in the job-template?
>
> I can't find a clear explanation for this, although there might be
> one I'm missing.  If I can find one, I'll add it to some sort of
> documentation.
>
> -i
>
> [1] https://review.openstack.org/#/c/212246
>
> _______________________________________________
> OpenStack-Infra mailing list
> OpenStack-Infra at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-infra
>



-- 
Darragh Bailey
"Nothing is foolproof to a sufficiently talented fool"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-infra/attachments/20150813/45fdc2b8/attachment.html>


More information about the OpenStack-Infra mailing list