gitness
gitness copied to clipboard
template converter: template name given not found
I cannot use template configuration
I created the template, but I will report an error when I build it
I created a template called notify.yaml, and I quoted it in my project. As shown in the figure
I found the same problem as me. Click Here
The drone-server is latest from docker hub (When I ask this question)
This is .drone.yaml
kind: pipeline
type: exec
name: wind
steps:
- name: build
commands:
- docker-compose -p wind_generator build
- name: start
commands:
- docker-compose -p wind_generator up -d
- name: test_live
commands:
- /bin/sh -c "sleep 2;if [ $(curl --noproxy "*" -o /dev/null -s -w %{http_code} -m 5 http://127.0.0.1:5200/liveprobe) = "200" ]; then echo "正常启动"; else echo "服务启动失败" && exit 1 ; fi"
trigger:
branch:
- master
event:
- push
- custom
---
kind: template
load: notify.yaml
data:
depends_on: wind
And this is notify.yaml
kind: pipeline
type: docker
name: default
clone:
disable: true
steps:
- name: email
image: drillster/drone-email
settings:
recipients:
from_secret: email_recipients
subject: "Drone build: [{{ build.status }}] {{ repo.name }} ({{ repo.branch }}) #{{ build.number }}"
host: smtp.qq.com
port: 465
from:
from_secret: email_user
username:
from_secret: email_user
password:
from_secret: email_password
trigger:
status: [success, failure]
depends_on:
- {{ .input.depends_on }}
You can see from the webpage that my template was successfully created.
I don't know why. My drone is started through docker.
I come from China, and the description language may not be so accurate. But I think I should still understand the problem I want to express.
The next day, I found a phenomenon. When I put .drone.yaml
After the content of yaml is deleted, only one template is retained, like this
kind: template
load: notify.yaml
data:
depends_on: wind
Then he can read the template I set
I think I can only find the answer by reading the source code of drone
Look what I found

- 采用了
yaml.Unmarshal
的方法,当我定义的kind: template 不在第一行时 - 第74行得到的
templateArgs.Load
是一个空字符串 - 这也就是为什么我定义的
.drone.yml
中的模板提示找不到的原因。希望能够对模板进行改进和优化。
Hi @xhatt You say you're using version 1.5.0 for drone server? Templating only became available on v2.1.0 See the changelog here: https://github.com/harness/drone/compare/v2.0.6...v2.1.0
你好@xhatt 你说你使用的是 1.5.0 版本的无人机服务器?模板仅在 v2.1.0 上可用 请在此处查看更改日志:v2.0.6...v2.1.0
I misread it. The version of drone-server is not 1.5. The version of drone-cli in the screenshot is 1.5.
I downloaded the latest image from docker hub. But I still can't. I checked the source code of drone and found the problem. I hope the official can update it
Hi @xhatt You say you're using version 1.5.0 for drone server? Templating only became available on v2.1.0 See the changelog here: v2.0.6...v2.1.0
When kind: template
is not in the first recognition area. templateArgs.Load
= ""
The main reason for this problem is the plugin/converter/template.go
line 74 the templateArgs.Load
obtained an empty string