How to pass parameter from jenkins to c# script

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.

Hello @Arunkumar and welcome to this community :wave:

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

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

@poddinue thanks for supporting.

string value= Environment.GetEnvironmentVariable(“Name”); same line I’m passing in my C# script.


but It’s couldn’t work…
please share the steps for–> how to pass parameter from Jenkins to C# script.
It’s enough to pass this to my C# script–> string value= Environment.GetEnvironmentVariable(“Name”);
1.i need to pass property file path in my jenkins job. how to get my property file path?
please share the freestyle job configure step–> how can i pass parameters and other setups.

1 Like

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…

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.

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

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.

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

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

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