简体   繁体   中英

How to assign value to azure devops variable using C#

I have selenium C# test script which can fetch the token from the browser.

I have two azure devops task one to execute the selenium test and another to execute API test. I want to pass the selenium test fetched token to API test execution task and for that I am trying to use azure user defined variable.

I tried doing Environment.SetEnvironmentVariable("Token", token); in my selenium test and then tried to access to token in other API task using $(Token) . But it is not working.

Can anyone please help with this. Is there a way to pass the token from selenium test to other azure-devops task?

Note:- Both tasks are in same job, one after the other.

You can use this example: Set a job-scoped variable from a script .

With C#, that`s maybe like the following:

Console.WriteLine("##vso[task.setvariable variable=Token]" + token);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM