On Wednesday, April 12, 2017 at 10:19:29 AM UTC+2, [email protected] 
wrote:
>
> As far as I can see the built-in Jinja filter escape does this, so for 
> example
>
> - name: escape
>   command: echo "{{ 'a&b' | escape }}"
>

Indeed yes, thank you Alexey!

среда, 30 ноября 2016 г., 21:41:16 UTC+7 пользователь 
> [email protected] написал:
>>
>> On Monday, November 7, 2016 at 3:15:59 PM UTC+1, [email protected] 
>> wrote:
>> Then, use it like this
>>
>>  - { role: jenkinspipelinejob, name: 'feeds', script: "{{ lookup('file', 
>> 'jenkins/jobs/feeds/script.groovy') | escape_xml_data }}" }
>>
>
So this should become

- { role: jenkinspipelinejob, name: 'feeds', script: "{{ lookup('file', 
'jenkins/jobs/feeds/script.groovy') *| escape* }}" }

but an even better way is to keep the "script" variable content unescaped, 
like:

- { role: jenkinspipelinejob, name: 'feeds', script: "{{ lookup('file', 
'jenkins/jobs/feeds/script.groovy') }}" } 

and escape it from the xml template:

$ cat roles/jenkinspipelinejob/
templates/config.xml.j2 

> <?xml version='1.0' encoding='UTF-8'?>
> <flow-definition plugin="[email protected]">
>   <actions/>
>   <description></description>
>   <keepDependencies>false</keepDependencies>
>   <properties>
>     
> <org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
>       <triggers/>
>     
> </org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
>   </properties>
>   <definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" 
> plugin="[email protected]">
>     <script>
> {{ script *| escape* }}
>     </script>
>     <sandbox>true</sandbox>
>   </definition>
>   <triggers/>
> </flow-definition>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3a521a92-b601-4fd1-8916-3c5d48241ec1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to