# Codefresh variables should be always available

**URL:** <https://community.codefresh.io/t/codefresh-variables-should-be-always-available/304>\
**Category:** Pipeline Workflows\
**Created:** [February 27, 2020, 12:53am UTC](https://community.codefresh.io/t/codefresh-variables-should-be-always-available/304 "2020-02-27T00:53:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![christian-roggia](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/christian-roggia/32/217_2.png) [@christian-roggia](https://community.codefresh.io/u/christian-roggia)\
**Post date:** [February 27, 2020, 12:53am UTC](https://community.codefresh.io/t/codefresh-variables-should-be-always-available/304/1 "2020-02-27T00:53:00Z")

</div>

Codefresh provides a mechanism that allows the pipelines to retrieve variables. The normal way to do so is to use the ${{VARIABLE}} format.

I have encountered multiple times an unexpected behavior while using this format: Whenever a variable is not available it does not get replaced and the placeholder simply stays there as-is.

As an example if I try to use the variable ${{MYVARIABLE} which has not been defined, the final YAML won’t have an empty string as a replacement to the placeholder, nor will the pipeline fail because there is an undefined variable. **The placeholder will simply stay there as it is.**

To make things even worse, the [system provided variable](https://codefresh.io/docs/docs/codefresh-yaml/variables/#system-provided-variables) that I always expected to be set to some value turned out not being set in multiple occasions.

I’d like to bring as an example the CF\_PULL\_REQUEST\_TARGET, the expected behavior is that this variable will be empty when the pipeline is manually run or the webhook event is not a pull request. The result instead is that the variable is not available and the placeholder doesn’t get replaced.

This behavior is also inconsistent with the normal behavior of the dollar $ in UNIX systems (e.g. `echo $MYVARIABLE`) used to access environment variables.

---

<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:** [February 27, 2020, 11:48am UTC](https://community.codefresh.io/t/codefresh-variables-should-be-always-available/304/2 "2020-02-27T11:48:42Z")

</div>

Hello

I passed your feedback to our dev team and they agree completely. We created an internal feature request and will plan soon.

---

<div class="post-metadata">

**Author:** ![christian-roggia](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/christian-roggia/32/217_2.png) [@christian-roggia](https://community.codefresh.io/u/christian-roggia)\
**Post date:** [February 27, 2020, 12:33pm UTC](https://community.codefresh.io/t/codefresh-variables-should-be-always-available/304/3 "2020-02-27T12:33:01Z")

</div>

Thank you very much!

As a side note, I think that undefined variables should just return a warning - and maybe a “strict mode” could be optionally enabled to force undefined variables to generate an error.

A strict mode could be used, of course, for other purposes as well.

---

<div class="post-metadata">

**Author:** ![kpurdon](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/kpurdon/32/400_2.png) [@kpurdon](https://community.codefresh.io/u/kpurdon)\
**Post date:** [August 20, 2021, 4:41pm UTC](https://community.codefresh.io/t/codefresh-variables-should-be-always-available/304/4 "2021-08-20T16:41:19Z")

</div>

Any update on this? I get bit by the placeholder getting used as the default value quite often. Making this more standard (empty string, or offer a default set mechanism) would be great.

---

<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:** [August 24, 2021, 12:06pm UTC](https://community.codefresh.io/t/codefresh-variables-should-be-always-available/304/5 "2021-08-24T12:06:18Z")

</div>

Hello

We have been discussing this issue internally for a long time. We agree that the requested behavior makes more sense. However, changing that now will break all existing pipelines for all customers. So it is a tradeoff between convenience and backwards compatibility.

Stay tuned, we have a possible solution in the works.

---

<div class="post-metadata">

**Author:** ![Jose\_Barahona](https://sea1.discourse-cdn.com/flex019/user_avatar/community.codefresh.io/jose_barahona/32/410_2.png) [@Jose\_Barahona](https://community.codefresh.io/u/Jose_Barahona)\
**Post date:** [September 24, 2021, 5:46pm UTC](https://community.codefresh.io/t/codefresh-variables-should-be-always-available/304/6 "2021-09-24T17:46:23Z")

</div>

We have any insigns or update on this issue?

right now my solution is create an step that read actually the property and set another variable and pass what to subsecuent pipelines.

```auto
setting_PR_vars:
    title: "settings pr vars" 
    image: xxxx
    stage: "xxxx"
 
    commands:
      - echo ${{CF_PULL_REQUEST_ACTION}}
      - cf_export CF_PULL_REQUEST_ACTION_PIPELINE=${{CF_PULL_REQUEST_ACTION}}
    when:
      condition:
        all:
          prActionOpen: '"${{CF_PULL_REQUEST_ACTION}}" == "opened"'

```

and then catch using on the next pipeline :

```auto
      VARIABLE:
        - CF_PULL_REQUEST_ACTION=${{CF_PULL_REQUEST_ACTION_PIPELINE}}

```

---

<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:** [October 4, 2021, 8:58am UTC](https://community.codefresh.io/t/codefresh-variables-should-be-always-available/304/7 "2021-10-04T08:58:23Z")

</div>

Hey Jose

Unfortunately no ETA yet.

I will update this thread when we have something solid.
