# Using Gitlab variable with newman

**URL:** <https://community.postman.com/t/using-gitlab-variable-with-newman/17569>\
**Category:** Help Hub\
**Created:** [November 10, 2020, 4:33pm UTC](https://community.postman.com/t/using-gitlab-variable-with-newman/17569 "2020-11-10T16:33:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikeccc](https://avatars.discourse-cdn.com/v4/letter/m/858c86/32.png) [@mikeccc](https://community.postman.com/u/mikeccc)\
**Post date:** [November 10, 2020, 4:33pm UTC](https://community.postman.com/t/using-gitlab-variable-with-newman/17569/1 "2020-11-10T16:33:18Z")

</div>

Hi, I setup newman to run my collections in gitlab pipeline. I wanted to allow the user to set a value for a Gitlab environement variable before running my newman test pipeline. I am wondering is there a possible way for newman to inject a gitlab variable and his value into the environment.json?

Thanks.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [November 10, 2020, 5:07pm UTC](https://community.postman.com/t/using-gitlab-variable-with-newman/17569/2 "2020-11-10T17:07:37Z")

</div>

Hey @mikeccc

Welcome to the community! 🏆

Depending on how you’re using Newman in your pipeline - You can add those Gitlab variables into the Collection like this?

From the CLI:

```auto
--env-var "variable_name=$GITLAB_VAR"

```

Newman as a library:

```auto
    envVar: [ 
        { "key":"variable_name", "value": $GITLAB_VAR}
    ]

```

If you wanted to share your pipeline file, I could give you a better/more focussed solution.

---

<div class="post-metadata">

**Author:** ![mikeccc](https://avatars.discourse-cdn.com/v4/letter/m/858c86/32.png) [@mikeccc](https://community.postman.com/u/mikeccc)\
**Post date:** [November 10, 2020, 6:20pm UTC](https://community.postman.com/t/using-gitlab-variable-with-newman/17569/3 "2020-11-10T18:20:28Z")

</div>

Thanks a lot @danny-dainton . I’ll give it a try. Thanks for the advice.  
Truly appreciated.

---

<div class="post-metadata">

**Author:** ![sristi0905](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sristi0905](https://community.postman.com/u/sristi0905)\
**Post date:** [October 14, 2021, 3:38pm UTC](https://community.postman.com/t/using-gitlab-variable-with-newman/17569/4 "2021-10-14T15:38:33Z")

</div>

Hi @danny-dainton ,

I tried this but It wont work for me.

1.Created one CICD variable name as Access\_Token.

2.Given variable in environment file like following -  
{  
“key”: “Access\_Token”,  
“value”: ​$Access\_Token​  
}

3.using following newman command -  
newman run APIQATEST.json -e APIQATEST\_environment.json --env-var “Access\_Token=$Access\_Token” --reporters cli,htmlextra --reporter-htmlextra-export report.html

I got error as -  
error: could not load environment

No value found for key value at 67:13

“value”: ​$Access\_Token​

Could you please let me know anything which I missed.

Best Regards,  
Sri

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 14, 2021, 4:07pm UTC](https://community.postman.com/t/using-gitlab-variable-with-newman/17569/5 "2021-10-14T16:07:11Z")

</div>

If you have the placeholder `{{Access_Token}}` in your Collection already, you don’t need to use an environment file with the command as it would resolve that to the value set in the `--env-var` flag.

Each CI tool has its own syntax it uses for variables and most are only uppercase - I’d be surprised it your one would work but you could also try echoing out the variable in the CI Tools console to ensure it’s resolving it correctly.

---

<div class="post-metadata">

**Author:** ![sristi0905](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sristi0905](https://community.postman.com/u/sristi0905)\
**Post date:** [October 14, 2021, 4:50pm UTC](https://community.postman.com/t/using-gitlab-variable-with-newman/17569/6 "2021-10-14T16:50:20Z")

</div>

Hi @danny-dainton ,

Thank You so much for quick reply. I just tried your suggested solution. It works for me.  
Much Appreciated.

Best Regards,  
Sristi
