Ansible Jinja template if statement
The syntax failures are caused by the presence of the {{...}} expression blocks (normally used for filling the template output with the corresponding content) inside the {%...%} statement blocks.

I only used standalone jinja2 templates, so I'm not 100% certain if this applies to Ansible jinja templates as well, but I suspect so. In the Jinja2 {%...%} statement blocks variables are referenced directly (and variable assignments are done in {% set ...%} statements), so what you're after may be along these lines:

{% set docker_compose_mq = &lt;string-passed from Jenkins&gt; %}
{% set docker_compose_profiles = "string" %}

{% if risk_docker_compose_mq == "string" %}
  {% set risk_docker_compose_profiles = "string1" %}
{% endif %}