Build variable not available in yml template?

According new feature template, I defined a yml template include build variables

  - name: notice
    image: lizheming/drone-wechat
      title: "{%if success %}😊{% else %}😭{% endif %} #{{.build.number}} {{}} ${DRONE_DEPLOY_TO}"

with failed error

function "build" not defined

Before I use template, use {{build.number}} works fine, how to translate this into yml template?

The template is evaluated before the build is created, and before the build number is auto-incremented. This means you cannot use {{build.number}} in your template because it is not yet available. You can find a list of available fields at

If build not available in template, there should be a way pass build varibles from .drone.yml to template,otherwise,we will never use build varibles with template or we can use build varibles but never use template, and we can’t use template and multi pipelines together…that seems not design logical

If build not available in template

{{ .build }} variables are supported, however, {{ .build.number }} is not a supported template variable. If you are interested in learning more about how it works you can audit the code here

{{ }} also not work?

when I remove build.number variable, got another error

executing "welcome.yaml" at <>: can't evaluate field name in type interface {}

Is there misunderstandings using variable in yaml template?

1 Like