microadam
(Adam Duncan)
February 15, 2018, 4:00pm
1
Hello,
Is there a complete list of “When” conditions documented anywhere? (or a link to the code, I had a look but couldn’t find it).
By this, I mean, what options you can put in the “when” conditions on each step i.e event, branch, ref, status etc
Many thanks!
1 Like
tonglil
(Tony)
February 20, 2018, 5:54pm
2
Hi @microadam , here is the documentation for step conditions: http://docs.drone.io/step-conditions/
There are also pipeline conditions (apply to all steps): http://docs.drone.io/pipeline-conditions/
Please take a look and send a PR if you feel like something is missing.
microadam
(Adam Duncan)
February 20, 2018, 7:29pm
3
Hi @tonglil . Yes, I am aware of those pages. However that literally only mentions branch
and event
. I am aware of others (only through seeing people mention things in discourse) such as ref
and status
, but I was hoping to find out a FULL list (unless those are literally the only 4 things available?). Happy to look through code for the list if needs be, but I am not a GO developer so wasn’t sure where I should be looking. If you could point me in the right direction, that would be great
tonglil
(Tony)
February 20, 2018, 7:56pm
4
Here are the constraints and some tests for them:
package yaml
import (
"testing"
yaml "gopkg.in/yaml.v2"
)
func TestConstraint(t *testing.T) {
testdata := []struct {
conf string
with string
want bool
}{
// string value
{
conf: "master",
with: "develop",
want: false,
},
This file has been truncated. show original
As far as I can tell, the documentation contains info for
There is no documentation for refs as mentioned in “Execute a build step only when a feature branch is tagged with a specific pattern? ”.
Feel free to send a PR to the docs about that one!
microadam
(Adam Duncan)
February 20, 2018, 8:06pm
5
Have the docs recently been updated? As I swear all that information wasn’t there last time I looked! Apologies for the oversight… I must be going mad.
Many thanks for all the links. Good to know that is the full list.
tonglil
(Tony)
February 20, 2018, 8:26pm
6
You might have been viewing a cached version of the docs.
CTRL+SHIFT+R
In drone 1.0.0, the URL changed for the “when” conditions.
They now live here: https://docs.drone.io/user-guide/pipeline/conditions/
func printConditions(w writer, name string, v yaml.Conditions) {
w.WriteTag(name)
w.IndentIncrease()
if !isConditionEmpty(v.Action) {
printCondition(w, "action", v.Action)
}
if !isConditionEmpty(v.Branch) {
printCondition(w, "branch", v.Branch)
}
if !isConditionEmpty(v.Cron) {
printCondition(w, "cron", v.Cron)
}
if !isConditionEmpty(v.Event) {
printCondition(w, "event", v.Event)
}
if !isConditionEmpty(v.Instance) {
printCondition(w, "instance", v.Instance)
}
if !isConditionEmpty(v.Paths) {
printCondition(w, "paths", v.Paths)
This file has been truncated. show original
// helper function pretty prints the conditions mapping.
func printConditions(w writer, name string, v yaml.Conditions) {
w.WriteTag(name)
w.IndentIncrease()
if !isConditionEmpty(v.Action) {
printCondition(w, "action", v.Action)
}
if !isConditionEmpty(v.Branch) {
printCondition(w, "branch", v.Branch)
}
if !isConditionEmpty(v.Cron) {
printCondition(w, "cron", v.Cron)
}
if !isConditionEmpty(v.Event) {
printCondition(w, "event", v.Event)
}
if !isConditionEmpty(v.Instance) {
printCondition(w, "instance", v.Instance)
}
if !isConditionEmpty(v.Paths) {
printCondition(w, "paths", v.Paths)
}
if !isConditionEmpty(v.Ref) {
printCondition(w, "ref", v.Ref)
}
if !isConditionEmpty(v.Repo) {
printCondition(w, "repo", v.Repo)
}
if !isConditionEmpty(v.Status) {
printCondition(w, "status", v.Status)
}
if !isConditionEmpty(v.Target) {
printCondition(w, "target", v.Target)
}
w.IndentDecrease()
}