# Full list of "When" conditions

**URL:** <https://drone.discourse.group/t/full-list-of-when-conditions/10705>\
**Category:** Drone Support\
**Created:** [February 15, 2018, 4:00pm UTC](https://drone.discourse.group/t/full-list-of-when-conditions/10705 "2018-02-15T16:00:28Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![microadam](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/microadam/32/3994_2.png) [@microadam](https://drone.discourse.group/u/microadam)\
**Post date:** [February 15, 2018, 4:00pm UTC](https://drone.discourse.group/t/full-list-of-when-conditions/10705/1 "2018-02-15T16:00:28Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![tonglil](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/tonglil/32/4225_2.png) [@tonglil](https://drone.discourse.group/u/tonglil)\
**Post date:** [February 20, 2018, 5:54pm UTC](https://drone.discourse.group/t/full-list-of-when-conditions/10705/2 "2018-02-20T17:54:44Z")

</div>

Hi @microadam, here is the documentation for step conditions: [http://docs.drone.io/step-conditions/](http://docs.drone.io/step-conditions/)

There are also pipeline conditions (apply to all steps): [http://docs.drone.io/pipeline-conditions/](http://docs.drone.io/pipeline-conditions/)

Please take a look and send a PR if you feel like something is missing.

---

<div class="post-metadata">

**Author:** ![microadam](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/microadam/32/3994_2.png) [@microadam](https://drone.discourse.group/u/microadam)\
**Post date:** [February 20, 2018, 7:29pm UTC](https://drone.discourse.group/t/full-list-of-when-conditions/10705/3 "2018-02-20T19:29:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tonglil](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/tonglil/32/4225_2.png) [@tonglil](https://drone.discourse.group/u/tonglil)\
**Post date:** [February 20, 2018, 7:56pm UTC](https://drone.discourse.group/t/full-list-of-when-conditions/10705/4 "2018-02-20T19:56:05Z")

</div>

Here are the constraints and some tests for them:

> <https://github.com/drone/drone-yaml-v1/blob/master/yaml/constraint.go#L7-L17>

  

> <https://github.com/drone/drone-yaml-v1/blob/master/yaml/constraint_test.go>

As far as I can tell, the documentation contains info for

- Branches: [http://docs.drone.io/step-conditions/#branches](http://docs.drone.io/step-conditions/#branches)
- Events: [http://docs.drone.io/step-conditions/#events](http://docs.drone.io/step-conditions/#events)
- Status: [http://docs.drone.io/step-conditions/#status](http://docs.drone.io/step-conditions/#status)
- Platform: [http://docs.drone.io/step-conditions/#platform](http://docs.drone.io/step-conditions/#platform)
- Environment: [http://docs.drone.io/step-conditions/#environment](http://docs.drone.io/step-conditions/#environment)
- Matrix: [http://docs.drone.io/step-conditions/#matrix](http://docs.drone.io/step-conditions/#matrix)
- Instance: [http://docs.drone.io/step-conditions/#instance](http://docs.drone.io/step-conditions/#instance)

There is no documentation for refs as mentioned in “[Execute a build step only when a feature branch is tagged with a specific pattern?](http://discuss.harness.io/t/execute-a-build-step-only-when-a-feature-branch-is-tagged-with-a-specific-pattern/1237)”.

Feel free to send a PR to the docs about that one!

---

<div class="post-metadata">

**Author:** ![microadam](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/microadam/32/3994_2.png) [@microadam](https://drone.discourse.group/u/microadam)\
**Post date:** [February 20, 2018, 8:06pm UTC](https://drone.discourse.group/t/full-list-of-when-conditions/10705/5 "2018-02-20T20:06:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tonglil](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/tonglil/32/4225_2.png) [@tonglil](https://drone.discourse.group/u/tonglil)\
**Post date:** [February 20, 2018, 8:26pm UTC](https://drone.discourse.group/t/full-list-of-when-conditions/10705/6 "2018-02-20T20:26:55Z")

</div>

You might have been viewing a cached version of the docs.  
CTRL+SHIFT+R 🙂

---

<div class="post-metadata">

**Author:** ![jnaulty](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@jnaulty](https://drone.discourse.group/u/jnaulty)\
**Post date:** [April 3, 2019, 4:34pm UTC](https://drone.discourse.group/t/full-list-of-when-conditions/10705/7 "2019-04-03T16:34:20Z")

</div>

In drone 1.0.0, the URL changed for the “when” conditions.  
They now live here: [https://docs.drone.io/user-guide/pipeline/conditions/](https://docs.drone.io/user-guide/pipeline/conditions/)

---

<div class="post-metadata">

**Author:** ![kalinchernev](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/kalinchernev/32/5274_2.png) [@kalinchernev](https://drone.discourse.group/u/kalinchernev)\
**Post date:** [October 28, 2019, 8:57am UTC](https://drone.discourse.group/t/full-list-of-when-conditions/10705/8 "2019-10-28T08:57:46Z")

</div>

they are here now [https://docs.drone.io/pipeline/conditions/](https://docs.drone.io/pipeline/conditions/)

---

<div class="post-metadata">

**Author:** ![quantonganh](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/quantonganh/32/5446_2.png) [@quantonganh](https://drone.discourse.group/u/quantonganh)\
**Post date:** [July 1, 2020, 3:46am UTC](https://drone.discourse.group/t/full-list-of-when-conditions/10705/9 "2020-07-01T03:46:36Z")

</div>

> <https://github.com/drone/drone-yaml/blob/master/yaml/pretty/pipeline.go#L122-L156>

```
// 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()
}
```
