# How to set default values for pipeline variables?

**URL:** <https://community.codefresh.io/t/how-to-set-default-values-for-pipeline-variables/822>\
**Category:** Pipeline Workflows\
**Created:** [July 10, 2022, 2:11pm UTC](https://community.codefresh.io/t/how-to-set-default-values-for-pipeline-variables/822 "2022-07-10T14:11:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hcandraw](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/hcandraw/32/524_2.png) [@hcandraw](https://community.codefresh.io/u/hcandraw)\
**Post date:** [July 10, 2022, 2:11pm UTC](https://community.codefresh.io/t/how-to-set-default-values-for-pipeline-variables/822/1 "2022-07-10T14:11:32Z")

</div>

Hello, is there anyway to set a default value for a pipeline variable? I’d like to have the variable available and overridable, but if it doesn’t get set, it should use the default value. Thanks.

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [July 11, 2022, 9:58am UTC](https://community.codefresh.io/t/how-to-set-default-values-for-pipeline-variables/822/2 "2022-07-11T09:58:30Z")

</div>

Yes we can put them on the project level and then override them in the pipeline level. Or put them in the pipeline level and override inside the yaml

Here are the rules

[https://codefresh.io/docs/docs/codefresh-yaml/variables/#user-provided-variables](https://codefresh.io/docs/docs/codefresh-yaml/variables/#user-provided-variables)

You can also use [Shared configuration · Codefresh | Docs](https://codefresh.io/docs/docs/configure-ci-cd-pipeline/shared-configuration/)

---

<div class="post-metadata">

**Author:** ![hcandraw](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/hcandraw/32/524_2.png) [@hcandraw](https://community.codefresh.io/u/hcandraw)\
**Post date:** [July 11, 2022, 10:57am UTC](https://community.codefresh.io/t/how-to-set-default-values-for-pipeline-variables/822/3 "2022-07-11T10:57:54Z")

</div>

Hi Kostis,

Our use case is we want to expose an optional pipeline variable. If the value of the variable is specified when executing the pipeline, then that is the value that would be used. If the value isn’t provided, the pipeline should be smart enough to detect this and use a default value.

My understanding is there’s no step out of the box as such provided by CodeFresh to provide a default value for an optional pipeline variable. We still need to write a step that checks this variable - if value doesn’t exist, cf\_export it with a default value.

Is this how you see this can be solved?

---

<div class="post-metadata">

**Author:** ![Kostis](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kostis/32/391_2.png) [@Kostis](https://community.codefresh.io/u/Kostis)\
**Post date:** [July 12, 2022, 11:02am UTC](https://community.codefresh.io/t/how-to-set-default-values-for-pipeline-variables/822/4 "2022-07-12T11:02:38Z")

</div>

Hello

You can do different steps according to the presence of a variable like this.

> **[Conditional execution of steps](https://codefresh.io/docs/docs/pipelines/conditional-execution-of-steps/#execute-steps-according-to-the-presence-of-a-variable)**
>
> Skip specific pipeline steps according to one or more conditions

would that work for you?
