I can't add a template from the CLI

I’m trying to test out the way templates work and I’m having trouble with the basics. I’m using the CLI tools v1.5.0 and configured them as shown here. I can list templates if I add them via the web interface.

I want to add a simple YAML template, but the syntax described in the docs doesn’t work. For example:

drone template add ryanjaeb my_template mytemplate.yaml

Outputs:

missing namespace

I need to use the options syntax described here. Ex:

drone template add --namespace ryanjaeb --name my_template mytemplate.yaml

However, I can never get past the following error, no matter what kind of syntax I try for supplying the file name.

client error 400: {"message":"Template extension invalid. Must be yaml, starlark or jsonnet"}

I’ve tried it in both Windows and Linux. What am I doing wrong?

I’m also wondering how the namespaces are scoped. In the UI, I have to add a template from the settings of a project, but it’s under the organization section. Does that mean the template is only usable for that project or can I use it for any project in the organization? Also, is there a way to have a globally usable template?

Thanks in advance for the help!

The template name must include a valid extension, in this case yaml. The reason is that Drone supports multiple template formats (yaml, jsonnet, etc) and requires an extension to properly identify the template format at runtime.

-drone template add --namespace ryanjaeb --name my_template      mytemplate.yaml
+drone template add --namespace ryanjaeb --name my_template.yaml @/path/to/mytemplate.yaml

Thanks. I had to use the options style syntax for data (--data "@{PWD}/mytemplate.yaml") rather than the argument style syntax, but the missing extension on the name was the main thing tripping me up.