# How to pass parameter from jenkins to c# script

**URL:** <https://community.jenkins.io/t/how-to-pass-parameter-from-jenkins-to-c-script/3554>\
**Category:** Using Jenkins\
**Tags:** question\
**Created:** [August 30, 2022, 4:51am UTC](https://community.jenkins.io/t/how-to-pass-parameter-from-jenkins-to-c-script/3554 "2022-08-30T04:51:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arunkumar](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Arunkumar](https://community.jenkins.io/u/Arunkumar)\
**Post date:** [August 30, 2022, 4:51am UTC](https://community.jenkins.io/t/how-to-pass-parameter-from-jenkins-to-c-script/3554/1 "2022-08-30T04:51:50Z")

</div>

[https://www.seleniumstutorial.com/passing-parameters-values-jenkins-selenium-c/](https://www.seleniumstutorial.com/passing-parameters-values-jenkins-selenium-c/)

As per above mentioned link i tried all the possible ways but couldn’t get the expected output.

Could you please suggest me solution like.

1. I want to pass parameter from Jenkins to my C# script and get the result output
2. What do I need to change in my C# script so that I can get parameters from Jenkins  
I need sample code for passing username and password from jenkins to C# script.

---

<div class="post-metadata">

**Author:** ![poddingue](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/poddingue/32/985_2.png) [@poddingue](https://community.jenkins.io/u/poddingue)\
**Post date:** [September 1, 2022, 7:19am UTC](https://community.jenkins.io/t/how-to-pass-parameter-from-jenkins-to-c-script/3554/2 "2022-09-01T07:19:01Z")

</div>

Hello @Arunkumar and welcome to this community 👋

How are you getting values in your `C#` script?  
Is it this way?

```auto
  string value= Environment.GetEnvironmentVariable("Name");

```

---

<div class="post-metadata">

**Author:** ![Arunkumar](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Arunkumar](https://community.jenkins.io/u/Arunkumar)\
**Post date:** [September 1, 2022, 8:28am UTC](https://community.jenkins.io/t/how-to-pass-parameter-from-jenkins-to-c-script/3554/6 "2022-09-01T08:28:51Z")

</div>

![parameter-2](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/d/d38cf8ed60ae9d5deaa0b0fab19dbb29bf552e85.png)

---

<div class="post-metadata">

**Author:** ![Arunkumar](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Arunkumar](https://community.jenkins.io/u/Arunkumar)\
**Post date:** [September 1, 2022, 8:30am UTC](https://community.jenkins.io/t/how-to-pass-parameter-from-jenkins-to-c-script/3554/8 "2022-09-01T08:30:23Z")

</div>

![execute window patch comment-8](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/f/f6bb104b409a4f80bdcb5484bc68e4a3e1571941.png)

---

<div class="post-metadata">

**Author:** ![Arunkumar](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Arunkumar](https://community.jenkins.io/u/Arunkumar)\
**Post date:** [September 1, 2022, 8:31am UTC](https://community.jenkins.io/t/how-to-pass-parameter-from-jenkins-to-c-script/3554/10 "2022-09-01T08:31:32Z")

</div>

![result-2](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/1/175509e1fbba9685394e285392a6d25bca392cc3.png)

---

<div class="post-metadata">

**Author:** ![Arunkumar](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Arunkumar](https://community.jenkins.io/u/Arunkumar)\
**Post date:** [September 1, 2022, 8:46am UTC](https://community.jenkins.io/t/how-to-pass-parameter-from-jenkins-to-c-script/3554/11 "2022-09-01T08:46:18Z")

</div>

Above mentioned my Project Configure Steps…

1. i want achieve pass parameter from Jenkin to C# script using freestyle project.
2. kindly suggest me the job configure steps like how to pass parameter and property file path settings.
3. give me some brief explanation documents.

I struggle lot to achieve this. Kindly help me to resolve this…

---

<div class="post-metadata">

**Author:** ![Arunkumar](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Arunkumar](https://community.jenkins.io/u/Arunkumar)\
**Post date:** [September 6, 2022, 5:19am UTC](https://community.jenkins.io/t/how-to-pass-parameter-from-jenkins-to-c-script/3554/12 "2022-09-06T05:19:14Z")

</div>

Actually I’m using this Environment class in my code but It’s not working.

string value= Environment.GetEnvironmentVariable(“Name”);

1.what setup need to add in the Jenkin configure page.  
2. This Environment class is enough to get parameter from jenkin.

---

<div class="post-metadata">

**Author:** ![halkeye](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/halkeye/32/8_2.png) [@halkeye](https://community.jenkins.io/u/halkeye)\
**Post date:** [September 6, 2022, 5:46am UTC](https://community.jenkins.io/t/how-to-pass-parameter-from-jenkins-to-c-script/3554/13 "2022-09-06T05:46:02Z")

</div>

merged your two posts as they seem to be thr same thing

> [@Arunkumar](#):
>
> 1.what setup need to add in the Jenkin configure page.

I can see from your many many screenshots you are using freestyle job, with a parameter, then a bunch of other plugins that pull in environment variables from past jobs.

I recommend starting small and simple.

Create a new freestyle job. Add a new parameter called FOOBAR (So there’s no chance of it colliding with anything else), then add a single batch step that just has `set` (which I believe prints out all environment variables in windows). Assuming you see that FOOBAR variable set to the value you expect move to the more complicated step.

Update the job to run a dotnet app that prints out all, or at least the FOOBAR variable.

Then if that works, enable any more of the other checkboxes you think you need and test again.

This way you are in control and know what is working and what isn’t.

> [@Arunkumar](#):
>
> This Environment class is enough to get parameter from jenkin.

Probably? Assuming that class reads environment variables yes it should.

---

<div class="post-metadata">

**Author:** ![Arunkumar](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Arunkumar](https://community.jenkins.io/u/Arunkumar)\
**Post date:** [September 6, 2022, 8:05am UTC](https://community.jenkins.io/t/how-to-pass-parameter-from-jenkins-to-c-script/3554/14 "2022-09-06T08:05:25Z")

</div>

![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/0/05fa35a01024aa9f50064079728a00e14c324640.png)

Step: 1 I’m Using string parameter like Name-FOOBAR and Default value-passing project url  
step: 2 In windows Batch comment just given set

---

<div class="post-metadata">

**Author:** ![Arunkumar](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Arunkumar](https://community.jenkins.io/u/Arunkumar)\
**Post date:** [September 6, 2022, 8:15am UTC](https://community.jenkins.io/t/how-to-pass-parameter-from-jenkins-to-c-script/3554/15 "2022-09-06T08:15:21Z")

</div>

![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/c/c622fcafbf65a5d1fda908f6d19396c07dfa9de9.png)

this is my Jenkin console output… i got all environment variable.

I’m running my project using Nunit console so I’m given Nunit console path to windows batch comment like **C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe**

next I’m passing My project .dll file path to windows batch comment like– **C:\Users\ATSTC004\source\repos\parameterdemo\parameterdemo\bin\Debug\parameterdemo.dll**

could you please say how can i call my key-value in windows batch comment.

for example:  
Name=value or $Name
