I try to setup drone with .drone.jsonnet
config with drone-convert-pathschanged plugin.
drone version 1.2.2
config:
{
"kind": "pipeline",
"type": "docker",
"name": "default",
"steps": [
{
name: "web",
image: "node",
commands: ["echo WEB UPDATED"],
when: {
branch: ["main"],
event: ["push"],
paths: {
include: ["web/**"],
},
},
}
],
}
generated .drone.yml
config (drone jsonnet
command):
---
kind: pipeline
type: docker
name: default
platform:
os: linux
arch: amd64
steps:
- name: web
image: node
commands:
- echo WEB UPDATED
when:
branch:
- main
event:
- push
paths:
- web/**
...
Note that paths
trigger doesn’t include include
key =(
sorry, not sure I understand the problem. The include
is optional and implicit. If include
is missing it is assumed, so this looks fine to me.
Hi! paths
trigger is provided by drone-convert-pathschanged plugin. Why do you think include
or exclude
key is optional? I cannot find anything about that in plugin’s README.
In our case this config works (this one is not auto-generated):
---
kind: pipeline
type: docker
name: default
platform:
os: linux
arch: amd64
steps:
- name: web
image: node
commands:
- echo WEB UPDATED
when:
branch:
- main
event:
- push
paths:
include:
- web/**
...
And this does not (auto-generated from .drone.jsonnet
):
---
kind: pipeline
type: docker
name: default
platform:
os: linux
arch: amd64
steps:
- name: web
image: node
commands:
- echo WEB UPDATED
when:
branch:
- main
event:
- push
paths:
- web/**
...
The convention in Drone is that include
is implicit and is option.
This yaml:
branch:
- master
- develop
Is shorthand for this yaml:
branch:
include:
- master
- develop
If the paths changed extension does not support this convention, I recommend sending them a pull request to implement custom unmarshaling to handle these different scenarios (below is the snippet we use in Drone to unmarshal conditions).
// UnmarshalYAML implements yml unmarshalling.
func (c *condition) UnmarshalYAML(unmarshal func(interface{}) error) error {
var out1 string
var out2 []string
var out3 = struct {
Include []string
Exclude []string
}{}
err := unmarshal(&out1)
if err == nil {
c.Include = []string{out1}
return nil
}
unmarshal(&out2)
unmarshal(&out3)
c.Exclude = out3.Exclude
c.Include = append(
out3.Include,
out2...,
)
return nil
}
1 Like
Oh, got you. Will sort it out with plugin creator. Thank you!