Drone Templates Not Working With Special Characters

I am trying to use templates to run the same steps on multiple repos but I have syntax errors while trying to use the slack notification step.

  • name: slack
    status: [ failure ]
    image: plugins/slack
    from_secret: slack_webhook
    from_secret: slack_channel
    link_names: true
    template: >
    {{#if build.pull }}
    {{#success build.status}}:heavy_check_mark:{{ else }}✘{{/success}} {{ uppercasefirst build.status }}: <https://github.com/{{ repo.owner }}/{{ repo.name }}/pull/{{ build.pull }}|Pull Request #{{ build.pull }}>
    {{#success build.status}}:heavy_check_mark:{{ else }}✘{{/success}} {{ uppercasefirst build.status }}: Build #{{ build.number }} (type: {{ build.event }})
    Building from the following commit-
    Commit: <https://github.com/{{ repo.owner }}/{{ repo.name }}/commit/{{ build.commit }}|{{ truncate build.commit 8 }}>
    Branch: <https://github.com/{{ repo.owner }}/{{ repo.name }}/commits/{{ build.branch }}|{{ build.branch }}>
    By: {{ build.author }}

The following step works perfectly if writing it to drone.yaml, but when using template it gives me the this error:

template: build_release_push.yaml:50: unexpected “#” in command.

Actually, I think the issue is a little different and might be with slack template itself.
I tried to delete the # section and it still gave me an error:

template: build_release_push.yaml:50: function “build” not defined

Hi @natali let me check around and get back to you.


Hi @natali can you send the execution link? for us to troubleshoot this issue.


We do not use Drone cloud, we implemented drone at our cluster so unfortunately I cannot share a link. But it happend to me while trying to run a templated pipeline with the step provided above

@natali ok, got it! Let me get back to you.


@natali the pipeline template feature uses the Go template language. The {{ and }} are reserved keywords in the Go template language. If you need to include {{ and }} in your pipeline template, they would need to be escaped, in accordance with the Go template escaping rules.


I’ll check it out. Thanks!

1 Like