# How to assign value to parameter defined in workflow

**URL:** <https://discuss.circleci.com/t/how-to-assign-value-to-parameter-defined-in-workflow/44290>\
**Category:** Build Environment\
**Created:** [June 2, 2022, 11:46am UTC](https://discuss.circleci.com/t/how-to-assign-value-to-parameter-defined-in-workflow/44290 "2022-06-02T11:46:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![onenessboy](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/onenessboy/32/30196_2.png) [@onenessboy](https://discuss.circleci.com/u/onenessboy)\
**Post date:** [June 2, 2022, 11:46am UTC](https://discuss.circleci.com/t/how-to-assign-value-to-parameter-defined-in-workflow/44290/1 "2022-06-02T11:46:12Z")

</div>

Hi

I have defined a parameter like now in .config.yml

```auto
  context_id:
    type: string
    default: ""

```

now in one of the job i am trying to assign to some jq json filtered value to this parameter so that i can use this variable later

```auto
      - run:
          name: check
          command: |                   
            jq -r 'values.id' /tmp/output.json >> ${context_id} \
            echo ${context_id} \

```

Error:

```auto
#!/bin/bash -eo pipefail
jq -r 'values.id' /tmp/output.json >> ${context_id} \
echo ${context_id} \     
cat /tmp/output.json

/bin/bash: ${context_id}: ambiguous redirect

Exited with code exit status 1
CircleCI received exit code 1

```

Please help

---

<div class="post-metadata">

**Author:** ![rit1010](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/rit1010/32/34738_2.png) [@rit1010](https://discuss.circleci.com/u/rit1010)\
**Post date:** [June 2, 2022, 8:45pm UTC](https://discuss.circleci.com/t/how-to-assign-value-to-parameter-defined-in-workflow/44290/2 "2022-06-02T20:45:02Z")

</div>

Parameters are accessed via the format of \<\< context\_id \>\> and environment variables ${context\_id}

Examples can be found here

```
  https://circleci.com/docs/2.0/pipeline-variables/
```

---

<div class="post-metadata">

**Author:** ![yannCI](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/yannci/32/24866_2.png) [@yannCI](https://discuss.circleci.com/u/yannCI)\
**Post date:** [June 9, 2022, 10:46pm UTC](https://discuss.circleci.com/t/how-to-assign-value-to-parameter-defined-in-workflow/44290/3 "2022-06-09T22:46:40Z")

</div>

Hi @onenessboy ,

As @rit1010 mentioned, parameters’ values are accessed using the syntax \<\< parameters._parameter\_name_ \>\>. However, it is not possible to assign a value directly to a parameter.

What you need to use, in this case, is the [`env_var_name` parameter type](https://circleci.com/docs/2.0/reusing-config/#environment-variable-name). You can then assign a value to the corresponding environment variable, and it’ll be passed on to the `env_var_name` parameter that refers to it.

The parameter value will then have to be accessed using the following syntax:  
**${\<\< parameters._parameter\_name_ \>\>}**

---

<div class="post-metadata">

**Author:** ![sywtech](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sywtech](https://discuss.circleci.com/u/sywtech)\
**Post date:** [March 30, 2023, 4:27pm UTC](https://discuss.circleci.com/t/how-to-assign-value-to-parameter-defined-in-workflow/44290/4 "2023-03-30T16:27:59Z")

</div>

Hi @yannCI,

I tried this syntax: ${\<\< parameters._parameter\_name_ \>\>} to access Circleci built-in environment variable: pipeline.number:  
echo “pipeline.number: ${\<\<pipeline.number\>\>}”

I got this error: /bin/bash: line 10: pipeline.number: ${\<\<pipeline.number\>\>}: bad substitution

---

<div class="post-metadata">

**Author:** ![rit1010](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/rit1010/32/34738_2.png) [@rit1010](https://discuss.circleci.com/u/rit1010)\
**Post date:** [March 30, 2023, 7:57pm UTC](https://discuss.circleci.com/t/how-to-assign-value-to-parameter-defined-in-workflow/44290/5 "2023-03-30T19:57:20Z")

</div>

Yes you will get an error as the text the circleci parser replaces an instance of \<\<something.something\>\> that it recognizes with its real value before the shell is executed so

so if \<\< pipeline.number\>\> is recognized as having the value of 10 by the circleci parser

What is being executed by bash in your example will be echo “pipeline.number: ${10}”

All you should need to enter is echo “pipeline.number: \<\<pipeline.number\>\>”

If you are seeing an error from within bash it is normally easy to debug as the pipeline report on the dashboard will show the exact shell script that is to be executed after the circleci parser has made its modifications/substitutions.

---

<div class="post-metadata">

**Author:** ![sywtech](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sywtech](https://discuss.circleci.com/u/sywtech)\
**Post date:** [March 30, 2023, 9:05pm UTC](https://discuss.circleci.com/t/how-to-assign-value-to-parameter-defined-in-workflow/44290/6 "2023-03-30T21:05:54Z")

</div>

@rit1010, thanks for your response! If I use this: echo “pipeline.number: \<\<pipeline.number\>\>”, I don’t get any error. But it does not interpolate the variable. It just prints: pipeline.number

---

<div class="post-metadata">

**Author:** ![rit1010](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/rit1010/32/34738_2.png) [@rit1010](https://discuss.circleci.com/u/rit1010)\
**Post date:** [March 30, 2023, 10:29pm UTC](https://discuss.circleci.com/t/how-to-assign-value-to-parameter-defined-in-workflow/44290/7 "2023-03-30T22:29:56Z")

</div>

I posted more to your other thread regarding that.

---

<div class="post-metadata">

**Author:** ![sywtech](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sywtech](https://discuss.circleci.com/u/sywtech)\
**Post date:** [March 31, 2023, 3:22pm UTC](https://discuss.circleci.com/t/how-to-assign-value-to-parameter-defined-in-workflow/44290/8 "2023-03-31T15:22:20Z")

</div>

Sorry, which other thread? I created only this one. Could you please post here?

Thank you!

---

<div class="post-metadata">

**Author:** ![sywtech](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sywtech](https://discuss.circleci.com/u/sywtech)\
**Post date:** [March 31, 2023, 3:23pm UTC](https://discuss.circleci.com/t/how-to-assign-value-to-parameter-defined-in-workflow/44290/9 "2023-03-31T15:23:54Z")

</div>

Ok, I see the other thread now, will respond there
